Solved

Can I jump to prior position on a CList ?

Posted on 2011-03-06
2
358 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
[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 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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

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…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

740 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