Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/boost/intrusive/detail/algorithm.hpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 //////////////////////////////////////////////////////////////////////////////
0002 //
0003 // (C) Copyright Ion Gaztanaga 2014-2014.
0004 //
0005 // Distributed under the Boost Software License, Version 1.0.
0006 // (See accompanying file LICENSE_1_0.txt or copy at
0007 // http://www.boost.org/LICENSE_1_0.txt)
0008 //
0009 // See http://www.boost.org/libs/intrusive for documentation.
0010 //
0011 //////////////////////////////////////////////////////////////////////////////
0012 
0013 #ifndef BOOST_INTRUSIVE_DETAIL_ALGORITHM_HPP
0014 #define BOOST_INTRUSIVE_DETAIL_ALGORITHM_HPP
0015 
0016 #ifndef BOOST_CONFIG_HPP
0017 #  include <boost/config.hpp>
0018 #endif
0019 
0020 #if defined(BOOST_HAS_PRAGMA_ONCE)
0021 #  pragma once
0022 #endif
0023 
0024 namespace boost {
0025 namespace intrusive {
0026 
0027 struct algo_pred_equal
0028 {
0029    template<class T, class T2>
0030    bool operator()(const T &x, const T2 &y) const
0031    {  return x == y;  }
0032 };
0033 
0034 struct algo_pred_less
0035 {
0036    template<class T, class T2>
0037    bool operator()(const T &x, const T2 &y) const
0038    {  return x < y;  }
0039 };
0040 
0041 template<class InputIt1, class InputIt2, class BinaryPredicate>
0042 bool algo_equal(InputIt1 first1, InputIt1 last1, InputIt2 first2, BinaryPredicate p)
0043 {
0044     for (; first1 != last1; ++first1, ++first2) {
0045         if (!p(*first1, *first2)) {
0046             return false;
0047         }
0048     }
0049     return true;
0050 }
0051 
0052 template<class InputIt1, class InputIt2, class BinaryPredicate>
0053 bool algo_equal(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, BinaryPredicate pred)
0054 {
0055     for (; first1 != last1 && first2 != last2; ++first1, ++first2)
0056         if (!pred(*first1, *first2))
0057             return false;
0058     return first1 == last1 && first2 == last2;
0059 }
0060 
0061 template<class InputIt1, class InputIt2>
0062 bool algo_equal(InputIt1 first1, InputIt1 last1, InputIt2 first2)
0063 {  return (algo_equal)(first1, last1, first2, algo_pred_equal());  }
0064 
0065 template<class InputIt1, class InputIt2>
0066 bool algo_equal(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2)
0067 {  return (algo_equal)(first1, last1, first2, last2, algo_pred_equal());  }
0068 
0069 template <class InputIterator1, class InputIterator2, class BinaryPredicate>
0070   bool algo_lexicographical_compare (InputIterator1 first1, InputIterator1 last1,
0071                                      InputIterator2 first2, InputIterator2 last2,
0072                                      BinaryPredicate pred)
0073 {
0074    while (first1 != last1){
0075       if (first2 == last2 || *first2 < *first1) return false;
0076       else if (pred(*first1, *first2)) return true;
0077       ++first1; ++first2;
0078    }
0079    return (first2 != last2);
0080 }
0081 
0082 template <class InputIterator1, class InputIterator2>
0083   bool algo_lexicographical_compare (InputIterator1 first1, InputIterator1 last1,
0084                                      InputIterator2 first2, InputIterator2 last2)
0085 {  return (algo_lexicographical_compare)(first1, last1, first2, last2, algo_pred_less());  }
0086 
0087 }  //namespace intrusive {
0088 }  //namespace boost {
0089 
0090 #endif   //#ifndef BOOST_INTRUSIVE_DETAIL_ALGORITHM_HPP