Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext
equal_range
Prototype

template<
    class ForwardRange,
    class Value
    >
std::pair<typename range_iterator<ForwardRange>::type,
          typename range_iterator<ForwardRange>::type>
equal_range(ForwardRange& rng, const Value& val);

template<
    class ForwardRange,
    class Value
    >
std::pair<typename range_iterator<const ForwardRange>::type,
          typename range_iterator<const ForwardRange>::type>
equal_range(const ForwardRange& rng, const Value& val);

template<
    class ForwardRange,
    class Value,
    class SortPredicate
    >
std::pair<typename range_iterator<ForwardRange>::type,
          typename range_iterator<ForwardRange>::type>
equal_range(ForwardRange& rng, const Value& val, SortPredicate pred);

template<
    class ForwardRange,
    class Value,
    class SortPredicate
    >
std::pair<typename range_iterator<const ForwardRange>::type,
          typename range_iterator<const ForwardRange>::type>
equal_range(const ForwardRange& rng, const Value& val, SortPredicate pred);

Description

equal_range returns a range in the form of a pair of iterators where all of the elements are equal to val. If no values are found that are equal to val, then an empty range is returned, hence result.first == result.second. For the non-predicate versions of equal_range the equality of elements is determined by operator<. For the predicate versions of equal_range the equality of elements is determined by pred.

Definition

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

Requirements

For the non-predicate versions:

For the predicate versions:

Precondition:

For the non-predicate versions: rng is ordered in ascending order according to operator<.

For the predicate versions: rng is ordered in ascending order according to pred.

Complexity

For random-access ranges, the complexity is O(log N), otherwise the complexity is O(N).


PrevUpHomeNext