CMapStringToOb::RemoveKey
Looks up the map entry corresponding to the supplied key; then, if the key is found, removes the entry.
BOOL RemoveKey(
LPCTSTR key
);
Параметры
- key
Specifies the string used for map lookup.
Возвращаемое значение
Nonzero if the entry was found and successfully removed; otherwise 0.
Заметки
This can cause memory leaks if the CObject object is not deleted elsewhere.
The following table shows other member functions that are similar to CMapStringToOb::RemoveKey.
Class |
Member Function |
---|---|
BOOL RemoveKey( void* key ); |
|
BOOL RemoveKey( void* key ); |
|
BOOL RemoveKey( LPCTSTR key ); |
|
BOOL RemoveKey( LPCTSTR key ); |
|
BOOL RemoveKey( WORD key ); |
|
BOOL RemoveKey( WORD key ); |
Пример
See CObList::CObList for a listing of the CAge class used in all collection examples.
CMapStringToOb map;
map.SetAt(_T("Bart"), new CAge(13));
map.SetAt(_T("Lisa"), new CAge(11));
map.SetAt(_T("Homer"), new CAge(36));
map.SetAt(_T("Marge"), new CAge(35));
map.RemoveKey(_T("Lisa")); // Memory leak: CAge object not
// deleted.
#ifdef _DEBUG
afxDump.SetDepth(1);
afxDump << _T("RemoveKey example: ") << &map << _T("\n");
#endif
The results from this program are as follows:
RemoveKey example: A CMapStringToOb with 3 elements
[Marge] = a CAge at $49A0 35
[Homer] = a CAge at $495E 36
[Bart] = a CAge at $4634 13
Требования
Header: afxcoll.h