它是c++支持的hash set,冲突时采用典型的链表法c++
template < class Key, // unordered_set::key_type/value_type class Hash = hash<Key>, // unordered_set::hasher class Pred = equal_to<Key>, // unordered_set::key_equal class Alloc = allocator<Key> // unordered_set::allocator_type > class unordered_set;
find(key)的流程:拿到key后,经过Hash函数计算hash值,而后对初始化设置的hash桶数取模,获得桶的索引,而后经过比较函数Pred比较桶索引中的元素值和查询key,获取比较结果,肯定是否查询到。函数
instert(key):也经过Hash函数计算hash值,获得桶索引,而后比较是否存在,若是不存在则插入。索引