libstdc++
GNU C++ library
Loading...
Searching...
No Matches

◆ unique() [1/2]

template<typename _Tp, typename _Alloc>
list< _Tp, _Alloc >::__remove_return_type list::unique ( )

Remove consecutive duplicate elements.

For each consecutive set of elements with the same value, remove all but the first one. Remaining elements stay in list order. Note that this function only erases the elements, and that if the elements themselves are pointers, the pointed-to memory is not touched in any way. Managing the pointer is the user's responsibility.

Definition at line 362 of file list.tcc.

364 {
366 iterator __last = end();
367 if (__first == __last)
368 return _GLIBCXX20_ONLY( 0 );
369#if !_GLIBCXX_USE_CXX11_ABI
371#endif
374 while (++__next != __last)
375 {
376 if (*__first == *__next)
377 {
379#if !_GLIBCXX_USE_CXX11_ABI
381#endif
382 }
383 else
384 __first = __next;
385 __next = __first;
386 }
387
388#if !_GLIBCXX_USE_CXX11_ABI
389 return _GLIBCXX20_ONLY( __removed );
390#else
392#endif
393 }
#define _GLIBCXX20_ONLY(__expr)
iterator begin() noexcept
Definition stl_list.h:1457
allocator_type get_allocator() const noexcept
Get a copy of the memory allocation object.
Definition stl_list.h:1447
size_type size() const noexcept
Definition stl_list.h:1586
_Node_traits::_Iterator iterator
Definition stl_list.h:1058
list()=default
Creates a list with no elements.
iterator end() noexcept
Definition stl_list.h:1477
size_t size_type
Definition stl_list.h:1062
void splice(const_iterator __position, list &&__x) noexcept
Insert contents of another list.
Definition stl_list.h:2102
A standard container with linear time access to elements, and fixed time insertion/deletion at any po...
Definition stl_list.h:1026

References list(), _GLIBCXX20_ONLY, begin(), end(), get_allocator(), size(), and splice().

Here is the call graph for this function: