Solved

Can I jump to prior position on a CList ?

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
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…

717 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