Solved

Can I jump to prior position on a CList ?

Posted on 2011-03-06
2
349 Views
Last Modified: 2012-05-11
Greetings,
I have a scenario where I have an outer look , where I iterate through information a result set of A CRecordset open operation and an inner loop, called multiple times per iteration of the outer loop, that also uses a sub-set of this information. In the current implementation I had a different CRecorset object in the function within the inner loop, performing database request for the sub-set of results it required.
 For a smart approach I want to perform only the outer query, stuff all the results in an object I can iterate on, and within the loop iterate through the same data set.
 However my worry is that after leaving the inner loop I want to have the iterator at the same position as when I entered it. Any suggestions? E.g. saving the POSITION object, returned in the GetNextPos and use the setAt funtion to put the iterator back into it's hold position?

Cheers,
r
0
Comment
Question by:rjorge
2 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
ID: 35046927
A POSITION is basically a 'CNode' with that being a
struct CNode
	{
		CNode* pNext;
		CNode* pPrev;
		TYPE data;
	};

Open in new window


So, if you store the POSITION you want to use further at a scope where is remains valid (i.e. outside both loop's bodies) you should be able to use it with 'CList::GetPrev()' to move to a prior position. That of course assumes the CList object is not altered during that process.
0
 

Author Closing Comment

by:rjorge
ID: 35047112
Quick and correct. Great info.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

706 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

19 Experts available now in Live!

Get 1:1 Help Now