C++ does list.unique() resize the list?

Go To StackoverFlow.com

0

Does a call of unique() on a list also resize the list if repeats are found?

2012-04-04 05:32
by user788171
... as opposed to std::unique, I suppose - visitor 2012-04-04 09:02


1

Yes, it does. It removes the duplicate elements. So the size of the list changes as well.

Have a look at the documentation here. It says:

The elements removed have their destructors called and their iterators and references become invalid.

Note that in case of std::list, while erasing an element, only the iterators and references to the erased element are invalidated [23.2.2.3/3].

2012-04-04 05:35
by Alok Save
Ads