[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: The perfect STL container

From: Torsten Mueller
Subject: Re: The perfect STL container
Date: Fri, 28 Sep 2012 16:05:51 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux)

ArbolOne <> schrieb:

> 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.

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.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]