CRBMultiMap::CRBMultiMap

构造函数。

explicit CRBMultiMap(
   size_t nBlockSize = 10 
) throw( );

参数

  • nBlockSize
    个大小。

备注

在需要时,nBlockSize 参数是内存分配的数量的度量新元素。更大的大小减少对内存分配例程,但是,使用多个资源。默认值一次将10个元素的空间。

为基类 CRBTree 参见文档以了解有关可用其他方法的信息。

示例

// Define a multimap object which has an integer
// key, a double value, and a block size of 5
CRBMultiMap<int, double> myMap(5);

// Add some key/values. Notice how three
// different values are associated with 
// one key. In a CRBMap object, the values
// would simply overwrite each other.
myMap.Insert(0, 1.1);
myMap.Insert(0, 1.2);
myMap.Insert(0, 1.3);
myMap.Insert(1, 2.1);

// Look up a key and iterate through
// all associated values

double v;
POSITION myPos = myMap.FindFirstWithKey(0);

while (myPos != NULL)
{
   v = myMap.GetNextValueWithKey(myPos,0);
   // As the loop iterates, v 
   // contains the values 1.3, 1.2, 1.1
}

// Remove all of the values associated with that key
size_t i = myMap.RemoveKey(0);

// Confirm all three values were deleted
ATLASSERT(i == 3);

要求

Header: atlcoll.h

请参见

参考

CRBMultiMap选件类

CRBMultiMap::~CRBMultiMap