linux下使用hash_map及STL总结

linux下使用hash_map及STL总结

    linux下使用hash_map及STL总结
    作者: zhdrfirst  时间: 2010-10-21

    出处:http://blog.chinaunix.net/u3/119070/showart_2363418.html

    hash_map不是C++标准库的一部分,但因其重要性很多库(如sgi stl、boost等)实现了hash_map,包括g++编译器所带的头文件也包含了hash_map的实现代码(其实现为sgi stl的版本),其在include/ext目录下,该目录还包含了hash_set,rope等的实现。

    // 文件/usr/include/c++/4.4.0/ext/hash_map

    _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
     65
     66 using std::equal_to;
     67 using std::allocator;
     68 using std::pair;
     69 using std::_Select1st;
     70
     71 /**
     72 * This is an SGI extension.
     73 * @ingroup SGIextensions
     74 * @doctodo
     75 */
     76 template<class _Key, class _Tp, class _HashFn = hash<_Key>,
     77 class _EqualKey = equal_to<_Key>, class _Alloc = allocator<_Tp> >
     78 class hash_map

    首先从上述头文件开始的部分可以发现,hash_map定义在__gnu_cxx命名空间中,故你必须在使用时限定名字空间__gnu_cxx::hash_map,或者使用using关键字,如下例:

    #include <ext/hash_map>
    using namespace __gnu_cxx;

    int main()
    {
        hash_map<int, string> hm;
        /* 其它使用hash_map的代码 */
    }

    STL其它头文件信息:

    1.几乎所有的容器都在同名的头文件里,比如,vector在<vector>中声明,list在<list>中声明等。例外的是<set>和<map>。<set>声明了set和multiset,<map>声明了map和multimap。

    2. 除了四个算法外,所有的算法都在<algorithm>中声明。例外的是accumulate、inner_product、adjacent_difference和partial_sum。这些算法在<numeric>中声明。

    3.特殊的迭代器,包括istream_iterators和istreambuf_iterators,在<iterator>中声明。

    4.标准仿函数(比如less<T>)和仿函数适配器(比如not1、bind2nd)在<functional>中声明。
posted on 2013-03-01 10:44  lexus 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/lexus/archive/2013/03/01/2938243.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值