[gameprogrammer] Re: stupid newbie question: iterating a map

  • From: "Mando Escamilla" <mando.escamilla@xxxxxxxxx>
  • To: gameprogrammer@xxxxxxxxxxxxx
  • Date: Mon, 16 Oct 2006 16:58:31 -0500

Roger,

It'll look something like this:

map<int, *Player> player_map;
map<int, *Player>::iterator player_iterator;

/* Add players to map */
.......

/* Iterate over map */
for (player_iterator = player_map.begin(); player_iterator !=
player_map.end(); player_iterator++) {
 int key  = player_iterator->first;
 *Player = player_iterator->second;
}

Or, at least something like that.

--
Mando
On 10/16/06, Roger D Vargas <luo_hei@xxxxxxxx> wrote:

Im using a map to represent a list of players, but I have found a problem I cant solve using the basic STL reference. I need to iterate through the whole list Supposing the list is defined as map<int,*playerclass> what is the correct way to get the data or the key from iterator?

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



Other related posts: