CObList::Find

Searches the list sequentially to find the first CObject pointer matching the specified CObject pointer.

POSITION Find(
   CObject* searchValue,
   POSITION startAfter = NULL 
) const;

Parameters

  • searchValue
    The object pointer to be found in this list.

  • startAfter
    The start position for the search.

Return Value

A POSITION value that can be used for iteration or object pointer retrieval; NULL if the object is not found.

Remarks

Note that the pointer values are compared, not the contents of the objects.

The following table shows other member functions that are similar to CObList::Find.

Class

Member Function

CPtrList

POSITION Find( void* searchValue, POSITION startAfter = NULL ) const;

CStringList

POSITION Find( LPCTSTR searchValue, POSITION startAfter = NULL ) const;

Example

See CObList::CObList for a listing of the CAge class.

CObList list;
CAge* pa1;
CAge* pa2;
POSITION pos;
list.AddHead(pa1 = new CAge(21));
list.AddHead(pa2 = new CAge(40));    // List now contains (40, 21).
if ((pos = list.Find(pa1)) != NULL) // Hunt for pa1
{                                  // starting at head by default.
    ASSERT(*(CAge*) list.GetAt(pos) == CAge(21));
}    

Requirements

Header: afxcoll.h

See Also

Reference

CObList Class

Hierarchy Chart

CObList::GetNext

CObList::GetPrev

Other Resources

CObList Members