다음을 통해 공유


CMapStringToOb::RemoveAll

Removes all the elements from this map and destroys the CString key objects.

void RemoveAll( );

Remarks

The CObject objects referenced by each key are not destroyed. The RemoveAll function can cause memory leaks if you do not ensure that the referenced CObject objects are destroyed.

The function works correctly if the map is already empty.

The following table shows other member functions that are similar to CMapStringToOb::RemoveAll.

Class

Member Function

CMapPtrToPtr

void RemoveAll( );

CMapPtrToWord

void RemoveAll( );

CMapStringToPtr

void RemoveAll( );

CMapStringToString

void RemoveAll( );

CMapWordToOb

void RemoveAll( );

CMapWordToPtr

void RemoveAll( );

Example

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

{
   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.         

Requirements

Header: afxcoll.h

See Also

Concepts

CMapStringToOb Class

CMapStringToOb Members

Hierarchy Chart

CMapStringToOb::RemoveKey