unique_copy

| Home | Libraries | People | FAQ | More

##### unique_copy

###### 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.