unique [C++ Reference]
Keywords: stl,list,unique
Date: 2008-10-14T15:42:06-0700

[[unique]]
C++ Reference
Translations of this page?:

- en
- br-pt
- cn
- cz
- de
- es
- fr
- it
- jp
- nl
- pl
- ro
- ru
- sk
- tr
- tw

## unique

Syntax:

        #include <list>
        void unique();
        void unique( BinPred pr );

The function unique() removes all consecutive duplicate elements from the list.

Note that only consecutive duplicates are removed, which may require that you sort() the list first.

Equality is tested using the == operator, unless pr is specified as a replacement. The ordering of the elements in a list should not change after a call to unique().

unique() runs in linear time.

Related Topics: List operators, remove, remove_if

Edit this page • Old revisions
• • • Login • Index • Recent changes • RSS • cc •