本文整理汇总了C++中HashMap::destroyKey方法的典型用法代码示例。如果您正苦于以下问题:C++ HashMap::destroyKey方法的具体用法?C++ HashMap::destroyKey怎么用?C++ HashMap::destroyKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HashMap
的用法示例。
在下文中一共展示了HashMap::destroyKey方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HashMap_DestroyElement
/*----------------------------------------------------------------------
* Destroy an element from the hash map.
* Both stored element and key are destroyed.
-----------------------------------------------------------------------*/
void HashMap_DestroyElement(HashMap map, HashMapKey key)
{
HashMapKeyNode keynode = HashMap_GetHashMapKeyNode(map, key, FALSE);
if (keynode!=NULL)
{
HashMapNode node = (HashMapNode)keynode->first;
while (node != NULL)
{
if (map->compare(key, node->key)==0)
{
if (node->key)
map->destroyKey(node->key);
DLList_DestroyElement((DLList)keynode, (DLListNode) node);
return;
}
node = node->next;
}
}
}
示例2: HashMap_Remove
/*----------------------------------------------------------------------
* Remove an element from the hash map and return it.
* The stored key is destroyed from the map.
-----------------------------------------------------------------------*/
ContainerElement HashMap_Remove(HashMap map, HashMapKey key)
{
HashMapKeyNode keynode = HashMap_GetHashMapKeyNode(map, key, FALSE);
if (keynode != NULL)
{
HashMapNode node = (HashMapNode)keynode->first;
while (node != NULL)
{
if (map->compare(key, node->key)==0)
{
if (node->key)
map->destroyKey(node->key);
return DLList_RemoveElement((DLList)keynode, (DLListNode) node);
}
node = node->next;
}
}
return NULL;
}