stl:algorithm:unique_copy

C++ Reference

unique_copy

Syntax:

    #include <algorithm>
    iterator unique_copy( iterator start, iterator end, iterator result );
    iterator unique_copy( iterator start, iterator end, iterator result, BinPred p );

The unique_copy() function copies the range [start,end) to result, removing all consecutive duplicate elements. If the binary predicate p is provided, then it is used to test two elements to see if they are duplicates.

The return value of unique_copy() is an iterator to the end of the new range.

unique_copy() runs in linear time.

Related Topics: adjacent_find, remove, unique