is_sorted_until函数源码
template <typename ForwardIterator, typename Pred>
ForwardIterator is_sorted_until ( ForwardIterator first, ForwardIterator last, Pred p )
{
if ( first == last ) return last; // the empty sequence is ordered
ForwardIterator next = first;
while ( ++next != last )
{
if ( p ( *next, *first ))
return next;
first = next;
}
return last;
}
本文件的最底层实现为is_sorted_until函数,其他函数都是通过间接调用此函数实现函数功能。
(1) is_sorted、is_increasing的Pred参数为C++的标准模板函数less;
(2) is_decreasing的Pred参数为C++的标准模板函数greater;
(3) is_strictly_increasing的Pred参数为C++的标准模板函数less_equal;
(4) is_strictly_decreasing的Pred参数为C++的标准模板函数greater_equal.