Share via


CAtlList::GetHeadPosition

 

Call this method to obtain the position of the head of the list.

Syntax

POSITION GetHeadPosition( ) const throw( );

Return Value

Returns the POSITION value corresponding to the element at the head of the list.

Remarks

If the list is empty, the value returned is NULL.

Example

// Define the integer list
CAtlList<int> myList;
int i;

// Populate the list
for (i = 0; i < 100; i++)
{
   myList.AddTail(i);
}

// Get the starting position value
POSITION myPos = myList.GetHeadPosition();

// Iterate through the entire list
i = 0;
int j;

do {
   j = myList.GetNext(myPos);
   ATLASSERT(i == j);
   i++;
} while (myPos != NULL);   

Requirements

Header: atlcoll.h

See Also

CAtlList Class
CAtlList::GetHead
CAtlList::GetTailPosition