Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

The perfect STL container

16 views
Skip to first unread message

ArbolOne

unread,
Sep 28, 2012, 8:51:34 AM9/28/12
to
Does STL have a container that would allow me to story only one copy of whatever data I am storing? For instance, in a data pool where there are several people named Mike, the container will only allow me to story the first person named Mike.

TIA

Torsten Mueller

unread,
Sep 28, 2012, 10:05:51 AM9/28/12
to
ArbolOne <Arbo...@gmail.com> schrieb:
Ordinary sets and a maps behave like this. Which element remains in the
container depends on the input method: a set stores always the last
added element, previously stored elements with the same key are removed
if you add a new one. A map shows the same behavior using the []
operator, but the insert method of a map refuses the insertion if an
element with that key already exists, so the first added element remains
in the container. Note: inserting values in large sets or maps can get
very slow because it's the most expensive operation on those containers.

T.M.
0 new messages