1 //////////////////////////////////////////////////////////////////////////////
3 // (C) Copyright Ion Gaztanaga 2014-2014.
5 // Distributed under the Boost Software License, Version 1.0.
6 // (See accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
9 // See http://www.boost.org/libs/container for documentation.
11 //////////////////////////////////////////////////////////////////////////////
13 #ifndef BOOST_CONTAINER_DETAIL_ALGORITHM_HPP
14 #define BOOST_CONTAINER_DETAIL_ALGORITHM_HPP
16 #ifndef BOOST_CONFIG_HPP
17 # include <boost/config.hpp>
20 #if defined(BOOST_HAS_PRAGMA_ONCE)
24 #include <boost/intrusive/detail/algorithm.hpp>
29 using boost::intrusive::algo_equal;
30 using boost::intrusive::algo_lexicographical_compare;
36 typedef typename Func::second_argument_type argument_type;
37 typedef typename Func::result_type result_type;
39 binder1st(const Func& func, const typename Func::first_argument_type& arg)
40 : op(func), value(arg)
43 result_type operator()(const argument_type& arg) const
44 { return op(value, arg); }
46 result_type operator()(argument_type& arg) const
47 { return op(value, arg); }
51 typename Func::first_argument_type value;
54 template<class Func, class T>
55 inline binder1st<Func> bind1st(const Func& func, const T& arg)
56 { return boost::container::binder1st<Func>(func, arg); }
62 typedef typename Func::first_argument_type argument_type;
63 typedef typename Func::result_type result_type;
65 binder2nd(const Func& func, const typename Func::second_argument_type& arg)
66 : op(func), value(arg)
69 result_type operator()(const argument_type& arg) const
70 { return op(arg, value); }
72 result_type operator()(argument_type& arg) const
73 { return op(arg, value); }
77 typename Func::second_argument_type value;
80 template<class Func, class T>
81 inline binder2nd<Func> bind2nd(const Func& func, const T& arg)
83 return (boost::container::binder2nd<Func>(func, arg));
90 typedef typename Func::argument_type argument_type;
91 typedef typename Func::result_type result_type;
93 explicit unary_negate(const Func& func)
97 bool operator()(const typename Func::argument_type& arg) const
98 { return !m_func(arg); }
104 template<class Func> inline
105 unary_negate<Func> not1(const Func& func)
107 return boost::container::unary_negate<Func>(func);
110 template<class InputIt, class UnaryPredicate>
111 InputIt find_if(InputIt first, InputIt last, UnaryPredicate p)
113 for (; first != last; ++first) {
121 template<class ForwardIt1, class ForwardIt2, class BinaryPredicate>
122 ForwardIt1 find_end (ForwardIt1 first1, ForwardIt1 last1
123 ,ForwardIt2 first2, ForwardIt2 last2
127 return last1; // specified in C++11
129 ForwardIt1 ret = last1;
131 while (first1!=last1)
133 ForwardIt1 it1 = first1;
134 ForwardIt2 it2 = first2;
135 while ( p(*it1, *it2) ) {
149 template<class InputIt, class ForwardIt, class BinaryPredicate>
150 InputIt find_first_of(InputIt first1, InputIt last1, ForwardIt first2, ForwardIt last2, BinaryPredicate p)
152 for (; first1 != last1; ++first1) {
153 for (ForwardIt it = first2; it != last2; ++it) {
154 if (p(*first1, *it)) {
162 template<class ForwardIt1, class ForwardIt2, class BinaryPredicate>
163 ForwardIt1 search(ForwardIt1 first1, ForwardIt1 last1,
164 ForwardIt2 first2, ForwardIt2 last2, BinaryPredicate p)
167 ForwardIt1 it = first1;
168 for (ForwardIt2 it2 = first2; ; ++it, ++it2) {
182 } //namespace container {
183 } //namespace boost {
185 #endif //#ifndef BOOST_CONTAINER_DETAIL_ALGORITHM_HPP