CObject*& GetPrev( POSITION& rPosition );
CObject* GetPrev( POSITION& rPosition ) const;
Return Value
See the return value description for GetHead.
Parameters
rPosition
A reference to a POSITION value returned by a previous GetPrev or other member function call.
Remarks
Gets the list element identified by rPosition, then sets rPosition to the POSITION value of the previous entry in the list. You can use GetPrev in a reverse iteration loop if you establish the initial position with a call to GetTailPosition or Find.
You must ensure that your POSITION value represents a valid position in the list. If it is invalid, then the Debug version of the Microsoft Foundation Class Library asserts.
If the retrieved element is the first in the list, then the new value of rPosition is set to NULL.
Example
CObList list;
POSITION pos;
list.AddHead( new CAge(21) );
list.AddHead( new CAge(40) ); // List now contains (40, 21).
// Iterate through the list in tail-to-head order.
for( pos = list.GetTailPosition(); pos != NULL; )
{
#ifdef _DEBUG
afxDump << list.GetPrev( pos ) << "\n";
#endif
}
The results from this program are as follows:
a CAge at $421C 21
a CAge at $421C 40
CObList Overview | Class Members | Hierarchy Chart
See Also CObList::Find, CObList::GetTailPosition, CObList::GetHeadPosition, CObList::GetNext, CObList::GetHead