unique_copy

Syntax:

    #include <algorithm>
    output_iterator unique_copy( input_iterator start, input_iterator end, output_iterator result );
    output_iterator unique_copy( input_iterator start, input_iterator end, output_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