CMap::GetSize

Returns the number of map elements.

INT_PTR GetSize( ) const;

Return Value

The number of items in the map.

Remarks

Call this method to retrieve the number of elements in the map.

Example

         CMap<int,int,CPoint,CPoint> myMap;

         myMap.InitHashTable(257);

         // Add 200 elements to the map.
         for (int i = 0; i < 200; i++)
            myMap[i] = CPoint(i, i);

         // Remove the elements with even key values.
         CPoint pt;
         for (int i = 0; myMap.Lookup(i, pt); i += 2)
         {
            myMap.RemoveKey(i);
         }

         ASSERT(myMap.GetSize() == 100);
         TRACE(_T("myMap with %d elements:\n"), myMap.GetCount());
           POSITION pos = myMap.GetStartPosition();
         int iKey;
         CPoint ptVal;
           while (pos != NULL)
           {
               myMap.GetNextAssoc(pos, iKey, ptVal);
               TRACE(_T("\t[%d] = (%d,%d)\n"), iKey, ptVal.x, ptVal.y);
         }

Requirements

Header: afxtempl.h

See Also

Reference

CMap Class

Hierarchy Chart

CMap::GetCount

Other Resources

CMap Members