Solved

pointer to stl Iterators ???

Posted on 2003-12-04
2
687 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org Go to that link and select download selenium in the right hand columnThat will then direct you to their download page.From that page s…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

733 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