Solved

Can I jump to prior position on a CList ?

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Is COM supported from Apache 1 52
Post a good COM tutorial 1 53
Using Diagnostic tools in VS2015: Unresoved allocations 19 82
Which Linux flavors will this run on? 6 87
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…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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.

813 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

16 Experts available now in Live!

Get 1:1 Help Now