// 实验hash表
ACE_Hash_Map_Manager<ACE_INT32, ACE_INT32, ACE_Null_Mutex> testHash;
// 插入数据
for (int i = 0; i < 9; i++)
{
testHash.bind (i, i);
}
// 遍历数据
for (ACE_Hash_Map_Manager<ACE_INT32, ACE_INT32,
ACE_Null_Mutex>::iterator iter = testHash.begin (); iter !=
testHash.end (); ++iter)
{
std::cout<<iter->int_id_<<endl;
}
// 查找数据
for (int j = 0; j < 9; j++)
{
ACE_INT32 data;
if(testHash.find (j,data) == 0)
{
std::cout<<data<<endl;
}
}
// 替换数据
for (int k = 0; k < 9; k++)
{
ACE_Hash_Map_Manager<ACE_INT32, ACE_INT32, ACE_Null_Mutex>::ENTRY * pEntry = NULL;
if(testHash.find (k,pEntry) == 0)
{
pEntry->int_id_ = 10;
}
}
for (iter = testHash.begin (); iter != testHash.end (); ++iter)
{
std::cout<<iter->int_id_<<endl;
}
// 情况数据
testHash.unbind_all();
// 哈希表实际大小和总大小(哈希桶数)
std::cout<<"testHash:"<<testHash.current_size()<<":"<<testHash.total_size()<<endl;
// 必须要求哈希表默认大小为1024
for (iter = testHash.begin (); iter != testHash.end (); ++iter)
{
std::cout<<iter->int_id_<<endl;
}
ACE_Hash_Map_Manager
转载本文章为转载内容,我们尊重原作者对文章享有的著作权。如有内容错误或侵权问题,欢迎原作者联系我们进行内容更正或删除文章。
下一篇:检查锁情况的三种方法
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
hash_map erase
一. hash_map 使用STL标准库时,如不了解其实现细节,很容易写出错误的代码。常见操作
hash_map 删除元素 迭代器 Java