ACE_Hash_Map_Manager

// 实验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;
}

posted @ 2012-10-15 22:59  dzqabc  阅读(2430)  评论(0编辑  收藏  举报