Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

unique_copy
PrevUpHomeNext
Prototype

template<class SinglePassRange, class OutputIterator>
OutputIterator unique_copy(const SinglePassRange& rng, OutputIterator out);

template<class SinglePassRange, class OutputIterator, class BinaryPredicate>
OutputIterator unique_copy(const SinglePassRange& rng, OutputIterator out, BinaryPredicate pred);

Description

unique_copy copies the first element of each sequence of duplicates encountered in rng to out.

Equality is determined by the predicate if one is supplied, or by operator==() for SinglePassRange's value type.

Definition

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

Requirements

For the non-predicate versions of unique:

  • SinglePassRange is a model of the Single Pass Range Concept.
  • SinglePassRange is mutable.
  • SinglePassRange's value type is a model of the EqualityComparableConcept.
  • OutputIterator is a model of the OutputIteratorConcept.

For the predicate versions of unique:

  • SinglePassRange is a model of the Single Pass Range Concept.
  • SinglePassRange is mutable.
  • BinaryPredicate is a model of the BinaryPredicateConcept.
  • SinglePassRange's value type is convertible to BinaryPredicate's first argument type and to BinaryPredicate's second argument type.
  • OutputIterator is a model of the OutputIteratorConcept.
Complexity

Linear. O(N) where N is distance(rng). Exactly distance(rng) comparisons are performed.


PrevUpHomeNext