Sign in to follow this  
hothead

when should i use iterators?

Recommended Posts

You can also use iterators to store a location in the std::list, std::map, etc. Note tho that this is for temporary or short-length situations at best, since changing the contents or ordering of the container could change the value of the iterator

Share this post


Link to post
Share on other sites
That is a secksy avatar. Kingdom Hearts, right? I wish I still had a PS2 just for that game. But then...that costs money.

Anyway, iterators are used to loop through things. Read this question half an hour ago and I decided to just leave it alone, but I, too, want you to elaborate upon the quEstIOn thaT is aTa HANDA, so thata I can'a HELPA you witha your pro-ba-leMA!

[/rant]

Share this post


Link to post
Share on other sites
Use iterators for two three things:

1. Where you used to use an index variable when looping through an array.

2. Where you used to use an index variable or pointer to refer to a specific element in an array.

3. Wacky C++ iterator stuff like ostream_iterator.

Share this post


Link to post
Share on other sites
Quote:
Original post by Boku San
That is a secksy avatar. Kingdom Hearts, right? I wish I still had a PS2 just for that game. But then...that costs money.

Anyway, iterators are used to loop through things. Read this question half an hour ago and I decided to just leave it alone, but I, too, want you to elaborate upon the quEstIOn thaT is aTa HANDA, so thata I can'a HELPA you witha your pro-ba-leMA!

[/rant]

its cloud from ff7 and thnks guys

Share this post


Link to post
Share on other sites
Iterators were created in C++ to simplify data retrival. I generally use them whenever I want to loop thru every element in a vector, queue, ect. That question is kind of like asking "when should I use a while loop" - it depends.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this