Udostępnij za pośrednictwem


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.

template< 
   typename K, 
   typename V, 
   class KTraits = CElementTraits< K >, 
   class VTraits = CElementTraits< V > 
> class CRBMultiMap : 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

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.

Requirements

Header: atlcoll.h

See Also

Reference

CRBTree Class

CAtlMap Class

CRBMap Class

Other Resources

CRBMultiMap Members

ATL Class Overview