Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=pacman-g2.git;a=commitdiff;h=d3983e65de8b4cdd22f402d4c51454d5af04ab33
commit d3983e65de8b4cdd22f402d4c51454d5af04ab33 Author: Michel Hermier <[email protected]> Date: Sun Sep 28 11:01:05 2014 +0200 libpacman: Add find_if_not to flib & FList. diff --git a/lib/libpacman/util/falgorithm.h b/lib/libpacman/util/falgorithm.h index 997c9bd..b6e4b24 100644 --- a/lib/libpacman/util/falgorithm.h +++ b/lib/libpacman/util/falgorithm.h @@ -82,6 +82,15 @@ namespace flib return first; } + template <class InputIterator, class UnaryPredicate> + InputIterator find_if_not(InputIterator first, InputIterator last, UnaryPredicate pred) + { + for(; first != last && pred(*first); ++first) { + /* Nothing to do but iterate */ + } + return first; + } + template <class T, class U> bool match(const T &val1, const U &val2) { diff --git a/lib/libpacman/util/flist.h b/lib/libpacman/util/flist.h index b17b900..81fcc76 100644 --- a/lib/libpacman/util/flist.h +++ b/lib/libpacman/util/flist.h @@ -733,6 +733,18 @@ public: return flib::find_if(begin(), end(), pred); } + template <class UnaryPredicate> + iterator find_if_not(UnaryPredicate pred) + { + return flib::find_if_not(begin(), end(), pred); + } + + template <class UnaryPredicate> + const_iterator find_if_not(UnaryPredicate pred) const + { + return flib::find_if_not(begin(), end(), pred); + } + /* Modifiers */ template <class Function = ::flib::detail::null_visitor> void clear(Function fn = Function()) _______________________________________________ Frugalware-git mailing list [email protected] http://frugalware.org/mailman/listinfo/frugalware-git
