Solved

pointer to stl Iterators ???

Posted on 2003-12-04
2
664 Views
Last Modified: 2013-12-14
Hi guys...
I wonder if there is possible to create a list of iterator pointers...
like this...

let's say i have a class called Object, and a list och Objects.
list<Object> objectList;

now if I search that list of objects with a iterator and find a object that I would like to "remeber" the position of...now, is there a possibility to have a pointer
that can point to these kind of iterators ?
or maybe even have another list of pointers to different iterator positions?

using std :: list<Object> :: iterator;
list<Iterator> iteratorList;  // ???

well I dont have any compilers yet so I cant test it :/
0
Comment
Question by:shdr
2 Comments
 
LVL 8

Accepted Solution

by:
mnashadka earned 125 total points
ID: 9877059
The iterator itself is kind of like a pointer, so you wouldn't need to create a list of pointers to iterators, only iterators.  It might look something like:
typedef std::list<Object>::iterator Iterator; // This just makes the next line a little cleaner
std::list<Iterator> iterators; // Create the list of iterators
// Add some iterators to the list
iterators.push_back(my_iterator);

// Then you can go through that list
for(std::list<Iterator>::iterator iter = iterators.begin(); iter != iterators.end(); ++iter)
{
  if((*iter)->x == 12) // You'll have to dereference the iterator to use it
  {
    do_something();
  }
}
0
 

Author Comment

by:shdr
ID: 9877253
thanks for the quick and helpful answer mnashadka, it worked :D
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now