Skip to content

Associative container

和原文的组织方式不同,基于是否ordered来进行分类。

cppreference Ordered associative containers

Associative containers implement sorted data structures that can be quickly searched (O(log n) complexity).

set collection of unique keys, sorted by keys (class template)
map collection of key-value pairs, sorted by keys, keys are unique (class template)
multiset collection of keys, sorted by keys (class template)
multimap collection of key-value pairs, sorted by keys (class template)

cppreference Unordered associative containers

Unordered associative containers implement unsorted (hashed) data structures that can be quickly searched (O(1) amortized, O(n) worst-case complexity).

unordered_set(C++11) collection of unique keys, hashed by keys (class template)
unordered_map(C++11) collection of key-value pairs, hashed by keys, keys are unique (class template)
unordered_multiset(C++11) collection of keys, hashed by keys (class template)
unordered_multimap(C++11) collection of key-value pairs, hashed by keys (class template)