|
-
November 24th, 2009, 09:05 PM
#11
Re: My new GoFish thread.
 Originally Posted by monarch_dodra
For iterator invalidation, but this is generally true when you use the stl:
You MUST know every container, and their functions by heart, and which invalidate what. It is easier if you understand how the container works. If you don't take the time to learn this, you will run into trouble.
As for random shuffle. It did not appear because it is a generic algorithm, like all algorithms in the stl. You are just supposed to call it between begin and end:
Code:
std::list<T> myList;
...
std::random_suffle(myList.begin(), myList.end());
It is true that some algorithms were re-written specifically for lists (sort comes to mind). But as a general rule, the algorithms are not member functions of your containers. This is what allows you to call them on anything, even plain old arrays!
UGH, I FORGOT... I feel so dumb. BTW, I JUST figured out my problem... I forgot the erase function.. when you say i = ***.erase(blah), it automatically moves the iterator to the next position... so I just added an else statement and it works perfectly now... ugh >_> THANK YOU SOOO MUCH <3
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|