[gameprogrammer] Re: stl container

Roger D Vargas wrote:
> Is there some stl strcture that let me store elements with multiple
> keys, and one of those keys repeated?

You mean, something like a std::map but one key can correspond to
multiple values?  You might try doing this:

        std::map< key_type, std::list<value_type> >

I'm not sure what you mean by "multiple keys," but if you mean you want
multiple key types all mapping to the same set of data, you can simply
use multiple maps, and use pointers for the value_type (so accessing a
value_type object from any map will return a pointer to one object,
rather than a copy stored in each map).  You have to be careful, in that
case, to remove an object from all maps before calling delete on the
pointer.
-- 
 Matthew Weigel
 hacker
 unique@xxxxxxxxxxx

---------------------
To unsubscribe go to http://gameprogrammer.com/mailinglist.html


Other related posts: