标签:style blog class code c ext
pair<iterator, bool> insert(const value_type& obj)
{
pair<typename ht::iterator, bool> p = rep.insert_unique(obj);
return pair<iterator, bool>(p.first, p.second);
}
private:
typedef hashtable<Value, Value, HashFcn, identity<Value>,
EqualKey, Alloc> ht;
ht rep; // 底层机制——hash table
public:
hash_set() : rep(100, hasher(), key_equal()) {} // 默认大小为100
#include <iostream>
#include <hash_set>
using namespace std;
using namespace __gnu_cxx;
int main()
{
hash_set<int> set;
set.insert(3);
set.insert(196);
set.insert(1);
set.insert(389);
set.insert(194);
set.insert(387);
hash_set<int>::iterator iter = set.begin();
for ( ; iter != set.end(); ++iter)
cout << *iter << ‘ ‘;
return 0;
}
关联容器 — hash_set,布布扣,bubuko.com
标签:style blog class code c ext
原文地址:http://blog.csdn.net/nestler/article/details/25592183