14 #ifndef STXXL_IS_SORTED_HEADER
15 #define STXXL_IS_SORTED_HEADER
17 #include <stxxl/bits/namespace.h>
20 __STXXL_BEGIN_NAMESPACE
22 template <
class _ForwardIter>
23 bool is_sorted_helper(_ForwardIter __first, _ForwardIter __last)
25 if (__first == __last)
28 _ForwardIter __next = __first;
29 for (++__next; __next != __last; __first = __next, ++__next) {
30 if (*__next < *__first)
37 template <
class _ForwardIter,
class _StrictWeakOrdering>
38 bool is_sorted_helper(_ForwardIter __first, _ForwardIter __last,
39 _StrictWeakOrdering __comp)
41 if (__first == __last)
44 _ForwardIter __next = __first;
45 for (++__next; __next != __last; __first = __next, ++__next) {
46 if (__comp(*__next, *__first))
53 template <
class _ForwardIter>
54 bool is_sorted(_ForwardIter __first, _ForwardIter __last)
56 return is_sorted_helper(__first, __last);
59 template <
class _ForwardIter,
class _StrictWeakOrdering>
60 bool is_sorted(_ForwardIter __first, _ForwardIter __last,
61 _StrictWeakOrdering __comp)
63 return is_sorted_helper(__first, __last, __comp);
68 #endif // !STXXL_IS_SORTED_HEADER