[gameprogrammer] Iterator question/organize a vector
- From: "David Olsen" <jolynsbass@xxxxxxxxx>
- To: <gameprogrammer@xxxxxxxxxxxxx>
- Date: Sun, 2 Mar 2008 23:07:10 -0600
Hi guys,
I'm just double checking on how to use iterators in my game. I have a list
of words, and the potential to re-arrange their order. Is this the correct
manner in which to do so with iterators:
a vector called "word", with iterator #1 (iter1) and iterator #2 (iter2).
iter2 is always the next vector element after iter1. (iter2 = iter1++)
in the event that I need to switch the two words, does this c++ code work?
word.insert(iter1,*iter2);
word.erase(iter2);
will this give me the expected result? or will I erase what's pointed to by
iter1, since I just added something in front of it, essentially putting it
in the place where iter2 has been pointing?
Thanks for the help!
-Dave
---------------------
To unsubscribe go to http://gameprogrammer.com/mailinglist.html
- Follow-Ups:
- [gameprogrammer] Re: Iterator question/organize a vector
- From: Chris Nystrom
- References:
- [gameprogrammer] Re: AI in games
- From: Robbert de Groot
Other related posts:
- » [gameprogrammer] Iterator question/organize a vector
- » [gameprogrammer] Re: Iterator question/organize a vector
- » [gameprogrammer] Re: Iterator question/organize a vector
- » [gameprogrammer] Re: Iterator question/organize a vector
- » [gameprogrammer] Re: Iterator question/organize a vector
- » [gameprogrammer] Re: Iterator question/organize a vector
- » [gameprogrammer] Re: Iterator question/organize a vector
- » [gameprogrammer] Re: Iterator question/organize a vector
- [gameprogrammer] Re: Iterator question/organize a vector
- From: Chris Nystrom
- [gameprogrammer] Re: AI in games
- From: Robbert de Groot