摘要:
在C++中用到map时,如果KEY是自定义的struct,那么需要自己定义比较函数。因为只有基本类型有默认的比较方法。定义的方法有两种,一是在作为key的struct中,重载操作符less(<),二是自定义仿函数作为map的比较函数,个人比较喜欢第二种方法。//自定义map的keytypedef struct UrlKey{ uint64_t dwBussID; uint64_t dwVersion; uint64_t dwHashUrl;}UrlKey;//自定义map的valuetypedef struct UrlValue{ string strUrl;}UrlValue;//ma 阅读全文
posted @ 2012-12-18 11:08
gmark
阅读(19112)
评论(1)
推荐(1)
浙公网安备 33010602011771号