CMapStringToOb::Lookup

CMapStringToOb::Lookup (查找)

BOOL Lookup( LPCTSTR key, CObject*& rValue ) const;

Return Value

Nonzero if the element was found; otherwise 0.

Parameters

key

Specifies the string key that identifies the element to be looked up.

rValue

Specifies the returned value from the looked-up element.(如果返回true,则rValue,返回元素中查找的值)

Remarks

Lookup uses a hashing algorithm to quickly find the map element with a key that matches exactly (CString value).

Example

See CObList::CObList for a listing of the CAge class used in all collection examples.

// example for CMapStringToOb::LookUp

CMapStringToOb map;
CAge* pa;

map.SetAt( "Bart", new CAge( 13 ) );
map.SetAt( "Lisa", new CAge( 11 ) );
map.SetAt( "Homer", new CAge( 36 ) );
map.SetAt( "Marge", new CAge( 35 ) );
ASSERT( map.Lookup( "Lisa", ( CObject*& ) pa ) ); // Is "Lisa" in the map?
ASSERT( *pa ==  CAge( 11 ) ); // Is she 11?

你可能感兴趣的:(CMapStringToOb::Lookup)