Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext
lexicographical_compare
Prototype

template<
    class SinglePassRange1,
    class SinglePassRange2
    >
bool lexicographical_compare(const SinglePassRange1& rng1,
                             const SinglePassRange2& rng2);

template<
    class SinglePassRange1,
    class SinglePassRange2,
    class BinaryPredicate
    >
bool lexicographical_compare(const SinglePassRange1& rng1,
                             const SinglePassRange2& rng2,
                             BinaryPredicate pred);

Description

lexicographical_compare compares element by element rng1 against rng2. If the element from rng1 is less than the element from rng2 then true is returned. If the end of rng1 without reaching the end of rng2 this also causes the return value to be true. The return value is false in all other circumstances. The elements are compared using operator< in the non-predicate versions of lexicographical_compare and using pred in the predicate versions.

Definition

Defined in the header file boost/range/algorithm/lexicographical_compare.hpp

Requirements

For the non-predicate versions of lexicographical_compare:

For the predicate versions of lexicographical_compare:

Complexity

Linear. At most 2 * min(distance(rng1), distance(rng2)) comparisons.


PrevUpHomeNext