Share via


CRBMap Class

This class represents a mapping structure, using a Red-Black binary tree.

template< 
   typename K,
   typename V,
   class KTraits = CElementTraits< K >,
   class VTraits = CElementTraits< V > 
> class CRBMap : public CRBTree< K, V, KTraits, VTraits >

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

CRBMap provides support for a mapping array of any given type, managing an ordered array of key elements and their associated values. Each key can have only one associated value. Elements (consisting of a key and a value) are stored in a binary tree structure, using the CRBMap::SetAt method. Elements can be removed using the CRBMap::RemoveKey method, which deletes the element with the given key value.

Traversing the tree is made possible with methods such as CRBTree::GetHeadPosition, CRBTree::GetNext, and CRBTree::GetNextValue.

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

CRBMap is derived from CRBTree, which implements a binary tree using the Red-Black algorithm. CRBMultiMap is a variation that allows multiple values for each key. It too is derived from CRBTree, and so shares many features with CRBMap.

An alternative to both CRBMap and CRBMultiMap is offered by the CAtlMap class. When only a small number of elements needs to be stored, consider using the CSimpleMap class instead.

For a more complete discussion of the various collection classes and their features and performance characteristics, see ATL Collection Classes.

Requirements

Header: atlcoll.h

See Also

Reference

CRBTree Class

CAtlMap Class

CRBMultiMap Class

Other Resources

CRBMap Members

ATL Class Overview