Standard C++ Library Reference ISO/IEC (VERSION3)
template<class BidIt, class Pr>
bool next_permutation(BidIt first, BidIt last,
Pr pred);
template<class BidIt>
bool prev_permutation(BidIt first, BidIt last);
template<class BidIt, class Pr>
bool prev_permutation(BidIt first, BidIt last,
Pr pred);
};
adjacent_find
template<class FwdIt>
FwdIt adjacent_find(FwdIt first, FwdIt last);
template<class FwdIt, class Pr>
FwdIt adjacent_find(FwdIt first, FwdIt last, Pr pred);
The first template function determines the lowest N in the range [0, last - first) for
which N + 1 < last - first and the predicate *(first + N) == *(first + N
+ 1) is true. Here, operator== must perform a pairwise comparison between its operands. It
then returns first + N. If no such value exists, the function returns last. If the sequence
contains fewer than two elements, the function never evaluates the predicate. Otherwise, if it
returns last, it evaluates the predicate exactly last - first - 1 times. Otherwise, it
evaluates the predicate exactly N + 1 times.
The second template function behaves the same, except that the predicate is pred(*(first +
N), *(first + N + 1)).
binary_search
template<class FwdIt, class Ty>
bool binary_search(FwdIt first, FwdIt last,
const Ty& val);
template<class FwdIt, class Ty, class Pr>
bool binary_search(FwdIt first, FwdIt last,
const Ty& val, Pr pred);
The first template function determines whether a value of N exists in the range [0, last -
first) for which *(first + N) has equivalent ordering to val, where the elements
designated by iterators in the range [first, last) form a sequence ordered by
operator<. If so, the function returns true. If no such value exists, it returns false.
Yhe function evaluates the ordering predicate X < Y at most ceil(log(last - first))
+ 2 times.