STL::unordered_map/unordered_multimap

unordered_map: 和 unorder_set 相似,该容器内部同样根据 hash value 把键值对存放到相应的 bucket(slot)中,根据单个 key 来访问 value 的速度很快。

unordered_multimap: 操作和 unorder_map 相同,不同点是 key 可以重复。通过 it.first(it->first) 访问 key 或者 it.second(it->second) 访问 mapped value。

Iterators(只有有序的容器才有 rbegin,rend 等迭代器)

begin:

end:

cbegin:

cend:

Capacity

empty:

size:

max_size:

Element access

operator [ ]:

at:

Element lookup

find:

count:

equal_range:

Modifiers

emplace:

emplace_hint:

insert:

erase: 三种方式 by position; by key; range;

clear:

swap:

Buckets

bucket_count:

max_bucket_count:

bucket_size:

bucket: 查询该 key 所在的 槽号。

Hash policy(同 unordered_set)

load_factor:

max_load_factor:

rehash:

reserve:

Observers

hash_function: 是 hasher 类型,获取当前的哈希函数。

key_eq:

猜你喜欢

转载自www.cnblogs.com/zpcoding/p/10338055.html