Table of Contents
Previous Section Next Section

unique and unique_copy

template <class ForIter>    ForIter unique(ForIter start, ForIter end);
template <class ForIter, class BinPred>
    ForIter unique(ForIter start, ForIter end, BinPred pfn);
template <class ForIter, class OutIter>
    OutIter unique_copy(ForIter start, ForIter end, OutIter result);
template <class ForIter, class OutIter, class BinPred>
    OutIter unique_copy(ForIter start, ForIter end, OutIter result,
                        BinPred pfn);

The unique( ) algorithm eliminates consecutive, duplicate elements from the specified range. The second form allows you to specify a binary predicate that determines when one element is equal to another. unique( ) returns an iterator to the end of the range.

The unique_copy( ) algorithm copies the range specified by start and end, eliminating consecutive duplicate elements in the process. The outcome is put into result. The second form allows you to specify a binary predicate that determines when one element is equal to another. unique_copy( ) returns an iterator to the end of the range.


Table of Contents
Previous Section Next Section