CMapStringToOb::RemoveAll

从此映射中移除所有元素并销毁 CString 键对象。

void RemoveAll( );

备注

销毁每个键引用的 CObject 对象。RemoveAll 函数会导致内存泄漏,如果不保证销毁引用的 CObject 对象。

如果映射已为空,该功能正常工作。

下表显示类似于 CMapStringToOb::RemoveAll的其他成员函数。

成员函数

CMapPtrToPtr

无效RemoveAll( );

CMapPtrToWord

无效RemoveAll( );

CMapStringToPtr

无效RemoveAll( );

CMapStringToString

无效RemoveAll( );

CMapWordToOb

无效RemoveAll( );

CMapWordToPtr

无效RemoveAll( );

示例

提供用于所有集合示例的列表 CAge 选件类参见 CObList::CObList

{
   CMapStringToOb map;

   CAge age1(13); // Two objects on the stack
   CAge age2(36);
   map.SetAt(_T("Bart"), &age1);
   map.SetAt(_T("Homer"), &age2);
   ASSERT(map.GetCount() == 2);
   map.RemoveAll(); // CObject pointers removed; objects not removed.
   ASSERT(map.GetCount() == 0);
   ASSERT(map.IsEmpty());
} // The two CAge objects are deleted when they go out of scope.         

要求

Header: afxcoll.h

请参见

参考

CMapStringToOb选件类

层次结构图

CMapStringToOb::RemoveKey