Unordered associative containers (C++): Difference between revisions

Content deleted Content added
cleanup, history section
Design: transform function list into a table
Line 15:
 
 
===Overview of functions===
 
**<code>unordered_map::[http://en.cppreference.com/w/cpp/container/unordered_map/unordered_map unordered_map]</code> (constructor) - Constructs the unordered map from variety of sources.
The containers are defined in headers named after the names of the containers, e.g. <code>unordored_set</code> is defined in header <code><unordered_set></code>. All containers satisfy the requirements of the [http://www.sgi.com/tech/stl/Container.html Container] [[concept (generic programming)|concept]], which means they have <code>begin()</code>, <code>end()</code>, <code>size()</code>, <code>max_size()</code>, <code>empty()</code>, and <code>swap()</code> methods.
**<code>unordered_map::[http://en.cppreference.com/w/cpp/container/unordered_map/~unordered_map ~unordered_map]</code> (destructor) - Destructs the unordered map and the contained elements
 
**<code>unordered_map::[http://en.cppreference.com/w/cpp/container/unordered_map/operator= operator=]</code> - Assigns values to the unordered map
{| class="wikitable" style="font-size:0.85em"
**<code>unordered_map::[http://en.cppreference.com/w/cpp/container/unordered_map/get_allocator get_allocator]</code> - Returns the allocator used to allocate memory for the elements
|-
*Iterators
!
**<code>unordered_map::[http://en.cppreference.com/w/cpp/container/unordered_map/begin begin]</code> - Returns an iterator to the beginning of the unordered map
! <code>unordered_set</code><br>([[C++11]])
**<code>unordered_map::[http://en.cppreference.com/w/cpp/container/unordered_map/end end]</code> - Returns an iterator to the end of the unordered map
! <code>unordered_map</code><br>([[C++11]])
* Capacity
! <code>unordered_multiset</code><br>([[C++11]])
**<code>unordered_map::[http://en.cppreference.com/w/cpp/container/unordered_map/empty empty]</code> - Checks whether the unordered map is empty
! <code>unordered_multimap</code><br>([[C++11]])
**<code>unordered_map::[http://en.cppreference.com/w/cpp/container/unordered_map/size size]</code> - Returns the number of elements in the unordered map.
! Description
**<code>unordered_map::[http://en.cppreference.com/w/cpp/container/unordered_map/max_size max_size]</code> - Returns the maximum possible number of elements in the unordered map.
|-
*Modifiers
! rowspan=4 |
**<code>unordered_map::[http://en.cppreference.com/w/cpp/container/unordered_map/clear clear]</code> - Clears the contents
**<code>unordered_map::| [http://en.cppreference.com/w/cpp/container/unordered_mapunordered_set/insertset insert(constructor)]</code> - Inserts elements
**<code>unordered_map::| [http://en.cppreference.com/w/cpp/container/unordered_map/emplacemap emplace(constructor)]</code> - Constructs elements in-place
**<code>unordered_map::| [http://en.cppreference.com/w/cpp/container/unordered_mapunordered_multiset/emplacemultiset emplace_hint(constructor)]</code> - Constructs elements in-place using a hint
**<code>unordered_map::| [http://en.cppreference.com/w/cpp/container/unordered_mapunordered_multimap/erasemultimap erase(constructor)]</code> - Erases elements
| Constructs the container from variety of sources
**<code>unordered_map::[http://en.cppreference.com/w/cpp/container/unordered_map/swap swap]</code> - Swaps the contents with another unordered map
|-
*Lookup
**<code>unordered_map::| [http://en.cppreference.com/w/cpp/container/unordered_mapunordered_set/count~set count(destructor)]</code> - Returns the number of elements matching specific key
**<code>unordered_map::| [http://en.cppreference.com/w/cpp/container/unordered_map/find~map find(destructor)]</code> - Finds an element with specific key
**<code>unordered_map::| [http://en.cppreference.com/w/cpp/container/unordered_mapunordered_multiset/equal_range~multiset equal_range(destructor)]</code> - Returns a range of elements matching specific key
| [http://en.cppreference.com/w/cpp/container/unordered_multimap/~multimap (destructor)]
*Bucket interface
| Destructs the set and the contained elements
** ...
|-
*Hash policy
| <code>[http://en.cppreference.com/w/cpp/container/unordered_set/operator= operator=]</code>
** ...
| <code>[http://en.cppreference.com/w/cpp/container/unordered_map/operator= operator=]</code>
*Observers
**| <code>unordered_map::[http://en.cppreference.com/w/cpp/container/unordered_mapunordered_multiset/hash_functionoperator= hash_functionoperator=]</code> - Returns the function used to create hash of a key
**| <code>unordered_map::[http://en.cppreference.com/w/cpp/container/unordered_mapunordered_multimap/key_eqoperator= key_eqoperator=]</code> - Returns key comparison function
| Assigns values to the container
|-
| <code>[http://en.cppreference.com/w/cpp/container/unordered_set/get_allocator get_allocator]</code>
| <code>[http://en.cppreference.com/w/cpp/container/unordered_map/get_allocator get_allocator]</code>
| <code>[http://en.cppreference.com/w/cpp/container/unordered_multiset/get_allocator get_allocator]</code>
| <code>[http://en.cppreference.com/w/cpp/container/unordered_multimap/get_allocator get_allocator]</code>
| Returns the allocator used to allocate memory for the elements
|-
! rowspan=2 | Element access
| {{n/a}}
| <code>[http://en.cppreference.com/w/cpp/container/unordered_map/at at]</code>
| {{n/a}}
| {{n/a}}
| Accesses specified element with bounds checking.
|-
| {{n/a}}
| <code>[http://en.cppreference.com/w/cpp/container/unordered_map/operator_at operator<nowiki>[]</nowiki>]</code>
| {{n/a}}
| {{n/a}}
| Accesses specified element without bounds checking.
|-
! rowspan=2 | Iterators
| <code>[http://en.cppreference.com/w/cpp/container/unordered_set/begin begin]</code>
| <code>[http://en.cppreference.com/w/cpp/container/unordered_map/begin begin]</code>
| <code>[http://en.cppreference.com/w/cpp/container/unordered_multiset/begin begin]</code>
| <code>[http://en.cppreference.com/w/cpp/container/unordered_multimap/begin begin]</code>
| Returns an iterator to the beginning of the container
|-
| <code>[http://en.cppreference.com/w/cpp/container/unordered_set/end end]</code>
| <code>[http://en.cppreference.com/w/cpp/container/unordered_map/end end]</code>
| <code>[http://en.cppreference.com/w/cpp/container/unordered_multiset/end end]</code>
| <code>[http://en.cppreference.com/w/cpp/container/unordered_multimap/end end]</code>
| Returns an iterator to the end of the container
|-
! rowspan=3 | Capacity
| <code>[http://en.cppreference.com/w/cpp/container/unordered_set/empty empty]</code>
| <code>[http://en.cppreference.com/w/cpp/container/unordered_map/empty empty]</code>
| <code>[http://en.cppreference.com/w/cpp/container/unordered_multiset/empty empty]</code>
| <code>[http://en.cppreference.com/w/cpp/container/unordered_multimap/empty empty]</code>
| Checks whether the container is empty
|-
| <code>[http://en.cppreference.com/w/cpp/container/unordered_set/size size]</code>
| <code>[http://en.cppreference.com/w/cpp/container/unordered_map/size size]</code>
| <code>[http://en.cppreference.com/w/cpp/container/unordered_multiset/size size]</code>
| <code>[http://en.cppreference.com/w/cpp/container/unordered_multimap/size size]</code>
| Returns number of elements in the container.
|-
| <code>[http://en.cppreference.com/w/cpp/container/unordered_set/max_size max_size]</code>
| <code>[http://en.cppreference.com/w/cpp/container/unordered_map/max_size max_size]</code>
| <code>[http://en.cppreference.com/w/cpp/container/unordered_multiset/max_size max_size]</code>
| <code>[http://en.cppreference.com/w/cpp/container/unordered_multimap/max_size max_size]</code>
| Returns the maximum possible number of elements in the container
|-
! rowspan=6 | Modifiers
| <code>[http://en.cppreference.com/w/cpp/container/unordered_set/clear clear]</code>
| <code>[http://en.cppreference.com/w/cpp/container/unordered_map/clear clear]</code>
| <code>[http://en.cppreference.com/w/cpp/container/unordered_multiset/clear clear]</code>
| <code>[http://en.cppreference.com/w/cpp/container/unordered_multimap/clear clear]</code>
| Clears the contents.
|-
| <code>[http://en.cppreference.com/w/cpp/container/unordered_set/insert insert]</code>
| <code>[http://en.cppreference.com/w/cpp/container/unordered_map/insert insert]</code>
| <code>[http://en.cppreference.com/w/cpp/container/unordered_multiset/insert insert]</code>
| <code>[http://en.cppreference.com/w/cpp/container/unordered_multimap/insert insert]</code>
| Inserts elements.
|-
| <code>[http://en.cppreference.com/w/cpp/container/unordered_set/emplace emplace]</code>
| <code>[http://en.cppreference.com/w/cpp/container/unordered_map/emplace emplace]</code>
| <code>[http://en.cppreference.com/w/cpp/container/unordered_multiset/emplace emplace]</code>
| <code>[http://en.cppreference.com/w/cpp/container/unordered_multimap/emplace emplace]</code>
| Constructs elements in-place ([[C++11]])
|-
| <code>[http://en.cppreference.com/w/cpp/container/unordered_set/emplace_hint emplace_hint]</code>
| <code>[http://en.cppreference.com/w/cpp/container/unordered_map/emplace_hint emplace_hint]</code>
| <code>[http://en.cppreference.com/w/cpp/container/unordered_multiset/emplace_hint emplace_hint]</code>
| <code>[http://en.cppreference.com/w/cpp/container/unordered_multimap/emplace_hint emplace_hint]</code>
| Constructs elements in-place using a hint ([[C++11]])
|-
| <code>[http://en.cppreference.com/w/cpp/container/unordered_set/erase erase]</code>
| <code>[http://en.cppreference.com/w/cpp/container/unordered_map/erase erase]</code>
| <code>[http://en.cppreference.com/w/cpp/container/unordered_multiset/erase erase]</code>
| <code>[http://en.cppreference.com/w/cpp/container/unordered_multimap/erase erase]</code>
| Erases elements.
|-
| <code>[http://en.cppreference.com/w/cpp/container/unordered_set/swap swap]</code>
| <code>[http://en.cppreference.com/w/cpp/container/unordered_map/swap swap]</code>
| <code>[http://en.cppreference.com/w/cpp/container/unordered_multiset/swap swap]</code>
| <code>[http://en.cppreference.com/w/cpp/container/unordered_multimap/swap swap]</code>
| Swaps the contents with another container.
|-
! rowspan=5 | Lookup
| <code>[http://en.cppreference.com/w/cpp/container/unordered_set/count count]</code>
| <code>[http://en.cppreference.com/w/cpp/container/unordered_map/count count]</code>
| <code>[http://en.cppreference.com/w/cpp/container/unordered_multiset/count count]</code>
| <code>[http://en.cppreference.com/w/cpp/container/unordered_multimap/count count]</code>
| Returns the number of elements matching specific key.
|-
| <code>[http://en.cppreference.com/w/cpp/container/unordered_set/find find]</code>
| <code>[http://en.cppreference.com/w/cpp/container/unordered_map/find find]</code>
| <code>[http://en.cppreference.com/w/cpp/container/unordered_multiset/find find]</code>
| <code>[http://en.cppreference.com/w/cpp/container/unordered_multimap/find find]</code>
| Finds an element with specific key.
|-
| <code>[http://en.cppreference.com/w/cpp/container/unordered_set/equal_range equal_range]</code>
| <code>[http://en.cppreference.com/w/cpp/container/unordered_map/equal_range equal_range]</code>
| <code>[http://en.cppreference.com/w/cpp/container/unordered_multiset/equal_range equal_range]</code>
| <code>[http://en.cppreference.com/w/cpp/container/unordered_multimap/equal_range equal_range]</code>
| Returns a range of elements matching specific key.
|-
! rowspan=1 | Bucket interface
| colspan=5 | ...
|-
! rowspan=1 | Hash policy
| colspan=5 | ...
|-
! rowspan=2 | Observers
| <code>[http://en.cppreference.com/w/cpp/container/unordered_set/hash_function hash_function]</code>
| <code>[http://en.cppreference.com/w/cpp/container/unordered_map/hash_function hash_function]</code>
| <code>[http://en.cppreference.com/w/cpp/container/unordered_multiset/hash_function hash_function]</code>
| <code>[http://en.cppreference.com/w/cpp/container/unordered_multimap/hash_function hash_function]</code>
| Returns the function used to create hash of a key
|-
| <code>[http://en.cppreference.com/w/cpp/container/unordered_set/key_eq key_eq]</code>
| <code>[http://en.cppreference.com/w/cpp/container/unordered_map/key_eq key_eq]</code>
| <code>[http://en.cppreference.com/w/cpp/container/unordered_multiset/key_eq key_eq]</code>
| <code>[http://en.cppreference.com/w/cpp/container/unordered_multimap/key_eq key_eq]</code>
| Returns key comparison function.
|}
 
==Usage example==