Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:30:42

0001 /*==============================================================================
0002     Copyright (c) 2010-2011 Bryce Lelbach
0003 
0004     Distributed under the Boost Software License, Version 1.0. (See accompanying
0005     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 ==============================================================================*/
0007 
0008 #ifndef BOOST_DETAIL_SORTED_HPP
0009 #define BOOST_DETAIL_SORTED_HPP
0010 
0011 #include <iterator>
0012 #include <functional>
0013 
0014 namespace boost {
0015 namespace detail {
0016 
0017 template<class Iterator, class Comp>
0018 inline Iterator is_sorted_until (Iterator first, Iterator last, Comp c) {
0019   if (first == last)
0020     return last;
0021 
0022   Iterator it = first; ++it;
0023 
0024   for (; it != last; first = it, ++it)
0025     if (c(*it, *first))
0026       return it;
0027 
0028   return it;
0029 }
0030 
0031 template<class Iterator>
0032 inline Iterator is_sorted_until (Iterator first, Iterator last) {
0033   typedef typename std::iterator_traits<Iterator>::value_type
0034     value_type;
0035 
0036   typedef std::less<value_type> c;
0037 
0038   return ::boost::detail::is_sorted_until(first, last, c());
0039 }
0040 
0041 template<class Iterator, class Comp>
0042 inline bool is_sorted (Iterator first, Iterator last, Comp c) {
0043   return ::boost::detail::is_sorted_until(first, last, c) == last;
0044 }
0045 
0046 template<class Iterator>
0047 inline bool is_sorted (Iterator first, Iterator last) {
0048   return ::boost::detail::is_sorted_until(first, last) == last;
0049 }
0050 
0051 } // detail
0052 } // boost
0053 
0054 #endif // BOOST_DETAIL_SORTED_HPP
0055