一位网友说他不能在ACE中正常地使用嵌套使Hash_Map,我写下下面的代码作了简单测试,发现在ACE使用Hasp_Map还是可以的.
// TestHaspMap.cpp:Definestheentrypointfortheconsoleapplication.
//
#include " stdafx.h "
#include " ACE/Basic_Types.h "
#include " ACE/Map_Manager.h "
#include " ACE/SString.h "
#include " ACE/Log_Msg.h "
#include " ACE/Null_Mutex.h "
class PhoneNumber
{
public :
PhoneNumber( const char * number):number_(number)
{
}
const char * getNumber( void )
{
return number_.c_str();
}
private :
ACE_SStringnumber_;
};
typedefACE_UINT16CONNECTION_ID;
typedefACE_Null_MutexMAP_MUTEX;
typedefACE_Map_Manager < CONNECTION_ID,PhoneNumber * ,MAP_MUTEX >
CONNECTION_MAP;
typedefACE_Map_Iterator < CONNECTION_ID,PhoneNumber * ,MAP_MUTEX >
CONNECTION_MAP_ITERATOR;
typedefACE_Map_Entry < CONNECTION_ID,PhoneNumber *>
CONNECTION_MAP_ENTRY;
typedefACE_Map_Manager < CONNECTION_ID,CONNECTION_MAP * ,MAP_MUTEX >
MAP_MAP;
typedefACE_Map_Iterator < CONNECTION_ID,CONNECTION_MAP * ,MAP_MUTEX >
MAP_MAP_ITERATOR;
typedefACE_Map_Entry < CONNECTION_ID,CONNECTION_MAP *>
MAP_MAP_ENTRY;
int ACE_TMAIN( int argc,_TCHAR * argv[])
{
CONNECTION_MAPconnection_map;
PhoneNumberme( " 13717928*** " );
PhoneNumberoffice( " 010-82378*** " );
PhoneNumberhome( " 13366686** " );
int result = - 1 ;
result = connection_map.bind( 1 , & me);
ACE_ASSERT(result == 0 );
result = connection_map.bind( 2 , & office);
ACE_ASSERT(result == 0 );
result = connection_map.bind( 3 , & home);
ACE_ASSERT(result == 0 );
result = connection_map.bind( 5 , & home);
ACE_ASSERT(result == 0 );
connection_map.unbind( 3 );
CONNECTION_MAP_ITERATORit(connection_map);
for (CONNECTION_MAP_ENTRY * i = 0 ;
it.next(i) != 0 ;
it.advance())
{
PhoneNumber * phone = i -> int_id_;
ACE_DEBUG((LM_INFO,ACE_TEXT( " 连接号码 %d,电话号码%s\n " ),
i -> ext_id_,
phone -> getNumber()));
}
PhoneNumber * any_phone = 0 ;
CONNECTION_IDany_id = 5 ;
result = connection_map.find(any_id,any_phone);
if (result != - 1 )
{
ACE_DEBUG((LM_INFO,ACE_TEXT( " 连接号码 %d,电话号码%s\n " ),
any_id,
any_phone -> getNumber()));
}
else
{
ACE_DEBUG((LM_INFO,ACE_TEXT( " 连接号码 %d,电话号码%s\n " ),
any_id,
" notfound. " ));
}
MAP_MAPmap_map;
map_map.bind( 1 , & connection_map);
size_tn = map_map.current_size();
MAP_MAP_ITERATORmap_it(map_map);
for (MAP_MAP_ENTRY * j = 0 ;
map_it.next(j) != 0 ;
map_it.advance())
{
CONNECTION_MAP * cur_map = j -> int_id_;
size_tcount = cur_map -> current_size();
PhoneNumber * any_phone2 = 0 ;
if (cur_map -> find( 2 ,any_phone2) !=- 1 )
{
ACE_DEBUG((LM_INFO,ACE_TEXT( " 内部map中电话号码%s\n " ),
any_phone2 -> getNumber()));
}
}
return 0 ;
}
分享到:
相关推荐
TBB 并发容器 concurrent_queue concurrent_vector concurrent_hash_map TBB 并发容器 concurrent_queue concurrent_vector concurrent_hash_map TBB 并发容器 concurrent_queue concurrent_vector concurrent_hash_...
在获取到mysql用户的hash后, 可用hash直接登陆mysql进行操作 比如我们注入出数据库的hash,但是没办法拿到webshell 我们可以使用mysql_hash,用hash登陆并控制数据库 使用方法: mysql_hash.exe -u root -p Enter ...
gen_lex_hash for pc,mysql交叉编译需要用到的文件,5.1.51 and 5.1.63两个版本,5.1.67版本始终编译不出来。有需要的下载。
Nginx:一致性哈希(第三方模块ngx_http_consistent_hash):ngx_http_consistent_hash-master.zip
基于应变和应力的Vumat子程序_hashin失效准则_动态应变_拉伸失效_hashin_vumat.zip
NGINX第三方模块:nginx_upstream_hash-0.3.1.tar.gz。
jg :: dense_hash_map 一个简单的std::unordered_map替代品,具有更好的性能,但失去了稳定的寻址方式,这是一种折衷方案。 在此处查看此哈希图的详细说明: : 生成状态: 特拉维斯(Travis):
linux 下hash_map的基本原理及使用,希望对大家有帮助。
用于复合材料损伤分析,三维损伤umat子程序
Nginx如何配置url_hash转发方式.docx
hash_map
Hash在线解密平台最新版php实现纯txt存储哈希跟明文对应表查询
url_hash 是nginx的第三方模块,nginx本身不支持,需要打patch . Url_hash 你nginx在做负载均衡的时候。把转发的URL 以hash的形式保存。这样可以保证同一个URL始终 分给同一个real server,来提高访问速度。
大数据 Map 哈希 价值五亿美元 Big Data Map hash value of five hundred million U.S. dollars
代码重点是hash_table,附加std::map与其做对比,实现的是一条sql语句:select c_nationkey, c_mktsegment, count(*), max(c_acctbal) from aaa_customer_1g group by c_nationkey, c_mktsegment order by c_...
随着C++0x标准的确立,C++的标准库中也终于有了hash table这个东西。...不过由于hash表的性能优势,它的使用面还是很广的,于是第三方的类库基本都提供了支持,比如MSVC中的<hash>和Boost中的<boost/unorde
NGINX第三方模块:nginx_upstream_hash-0.3.2版本。。。
关于hash_map的用法与解释: #include <hash_map> #include #include using namespace std; //define the class class ClassA{ public: ClassA(int a):c_a(a){} int getvalue()const { return c_a;} void ...
Hash基础知识_Hash基础知识_Hash基础知识_Hash基础知识_Hash基础知识_Hash基础知识_