Share via


CAtlList::Find

Call this method to search the list for the specified element.

POSITION Find( 
   INARGTYPE element, 
   POSITION posStartAfter = NULL  
) const throw( );

Parameters

  • element
    The element to be found in the list.

  • posStartAfter
    The start position for the search. If no value is specified, the search begins with the head element.

Return Value

Returns the POSITION value of the element if found, otherwise returns NULL.

Remarks

In debug builds, an assertion failure will occur if the list object is not valid, or if the posStartAfter value is out of range.

Example

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

// Populate the list
myList.AddTail(100);
myList.AddTail(200);
myList.AddTail(300);
myList.AddTail(400);

// Find the '300' element in the list, 
// starting from the list head.
POSITION myPos = myList.Find(300);

// Confirm that the element was found
ATLASSERT(myList.GetAt(myPos) == 300);   

Requirements

Header: atlcoll.h

See Also

Reference

CAtlList Class

CAtlList::FindIndex

Other Resources

CAtlList Members