Compartir a través de


CAtlMap Class

This class provides methods for creating and managing a map object.

template<
      typename K,
      typename V,
      class KTraits = CElementTraits< K >,
      class VTraits = CElementTraits< V >
>
class CAtlMap

Parameters

  • K
    The key element type.

  • V
    The value element type.

  • KTraits
    The code used to copy or move key elements. See CElementTraits Class for more details.

  • VTraits
    The code used to copy or move value elements.

Remarks

CAtlMap provides support for a mapping array of any given type, managing an unordered array of key elements and their associated values. Elements (consisting of a key and a value) are stored using a hashing algorithm, allowing a large amount of data to be efficiently stored and retrieved.

The KTraits and VTraits parameters are traits classes that contain any supplemental code needed to copy or move elements.

An alternative to CAtlMap is offered by the CRBMap class. CRBMap also stores key/value pairs, but exhibits different performance characteristics. The time taken to insert an item, look up a key, or delete a key from a CRBMap object is of order log(n), where n is the number of elements. For CAtlMap, all of these operations typically take a constant time, although worst-case scenarios might be of order n. Therefore, in a typical case, CAtlMap is faster.

The other difference between CRBMap and CAtlMap becomes apparent when iterating through the stored elements. In a CRBMap, the elements are visited in a sorted order. In a CAtlMap, the elements are not ordered, and no order can be inferred.

When a small number of elements need to be stored, consider using the CSimpleMap class instead.

For more information, see ATL Collection Classes.

Requirements

Header: atlcoll.h

See Also

Concepts

Marquee Sample: Provides Performance Monitoring Data Through Scripting

UpdatePV Sample: Implements an Updatable OLE DB Provider

CAtlMap Members

ATL Class Overview