[gameprogrammer] Re: stl container
- From: Roger D Vargas <luo_hei@xxxxxxxx>
- To: gameprogrammer@xxxxxxxxxxxxx
- Date: Wed, 29 Aug 2007 17:19:45 -0400
What i need is something like this:
<unique id, non unique id, data>
And the container should be able to return an iterator of all data for a
certain non unique id. I have a hash map of entities, each one with its
id, but I would also like to access a group of them located in the same
place (map). Thats why I was thinking in some quick solution like that.
Matthew Weigel escribió:
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.
--
http://dsgp.blogspot.com | Linux, programación, juegos
Have no place I can be since I found Serenity
But you can’t take the sky from me
______________________________________________
LLama Gratis a cualquier PC del Mundo.
Llamadas a fijos y móviles desde 1 céntimo por minuto.
http://es.voice.yahoo.com
---------------------
To unsubscribe go to http://gameprogrammer.com/mailinglist.html
- Follow-Ups:
- [gameprogrammer] Re: stl container
- From: Matthew Weigel
- [gameprogrammer] Re: stl container
- From: Yasser Gonzalez Soto
- References:
- [gameprogrammer] stl container
- From: Roger D Vargas
- [gameprogrammer] Re: stl container
- From: Matthew Weigel
Other related posts:
- » [gameprogrammer] stl container
- » [gameprogrammer] Re: stl container
- » [gameprogrammer] Re: stl container
- » [gameprogrammer] Re: stl container
- » [gameprogrammer] Re: stl container
- » [gameprogrammer] Re: stl container
- » [gameprogrammer] Re: stl container
- » [gameprogrammer] Re: stl container
- » [gameprogrammer] Re: stl container
- » [gameprogrammer] Re: stl container
- » [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.
- [gameprogrammer] Re: stl container
- From: Matthew Weigel
- [gameprogrammer] Re: stl container
- From: Yasser Gonzalez Soto
- [gameprogrammer] stl container
- From: Roger D Vargas
- [gameprogrammer] Re: stl container
- From: Matthew Weigel