This documentation is archived and is not being maintained.

CRBMultiMap Class

This class represents a mapping structure that allows each key can be associated with more than one value, using a Red-Black binary tree.

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


The key element type.


The value element type.


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


The code used to copy or move value elements.

CRBMultiMap provides support for a mapping array of any given type, managing an ordered array of key elements and values. Unlike the CRBMap class, each key can be associated with more than one value.

Elements (consisting of a key and a value) are stored in a binary tree structure, using the CRBMultiMap::Insert method. Elements can be removed using the CRBMultiMap::RemoveKey method, which deletes all elements which match the given key.

Traversing the tree is made possible with methods such as CRBTree::GetHeadPosition, CRBTree::GetNext, and CRBTree::GetNextValue. Accessing the potentially multiple values per key is possible using the CRBMultiMap::FindFirstWithKey, CRBMultiMap::GetNextValueWithKey, and CRBMultiMap::GetNextWithKey methods. See the example for CRBMultiMap::CRBMultiMap for an illustration of this in practice.

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

CRBMultiMap is derived from CRBTree, which implements a binary tree using the Red-Black algorithm. An alternative to CRBMultiMap and CRBMap 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.

Header: atlcoll.h