Template Class unordered_map

Class Documentation

template <class Key, class T, class Hash = shad::hash<Key>>
class unordered_map

Distributed unordered associative map.

A distributed associative container that contains key-value pairs with unique keys. Search, insertion, and removal of elements have average constant-time complexity. Internally, the elements are not sorted in any particular order, but organized into buckets. Which bucket an element is placed into depends entirely on the hash of its key. This allows fast access to individual elements, since once the hash is computed, it refers to the exact bucket the element is placed into.

Template Parameters
  • Key: The type of the keys.
  • T: The type of the mapped values.
  • Hash: The type of the hashing callable.

Public Types

template<>
using key_type = Key
template<>
using mapped_type = T

The type of the mapped elements.

template<>
using value_type = typename hashmap_t::value_type

The type of the stored value.

template<>
using size_type = std::size_t

The type used to represent size.

template<>
using difference_type = std::ptrdiff_t

The type used to represent distances.

template<>
using pointer = value_type *

The type for pointer to ::value_type.

template<>
using const_pointer = const value_type *

The type for pointer to ::const_value_type.

template<>
using iterator = typename hashmap_t::iterator

The type of iterators on the map.

template<>
using const_iterator = typename hashmap_t::const_iterator

The type of const iterators on the map.

template<>
using local_iterator = typename hashmap_t::local_iterator

The type of local iterators on the map.

template<>
using const_local_iterator = typename hashmap_t::const_local_iterator

The type of const local iterators on the map.

Public Functions

unordered_map(size_type bucket_count = 1021, const Hash &hash = Hash())

Constructor.

Parameters
  • bucket_count: The minimum number of buckets.
  • hash: The hashing callable.

~unordered_map()

Destructor.

iterator begin()
const_iterator begin() const

The iterator to the beginning of the sequence.

Return
a ::const_iterator to the beginning of the sequence.

const_iterator cbegin() const

The iterator to the beginning of the sequence.

Return
a ::const_iterator to the beginning of the sequence.

iterator end()

The iterator to the end of the sequence.

Return
a ::const_iterator to the end of the sequence.

const_iterator end() const

The iterator to the end of the sequence.

Return
a ::const_iterator to the end of the sequence.

const_iterator cend() const

The iterator to the end of the sequence.

Return
a ::const_iterator to the end of the sequence.

bool empty() const
size_type size() const

The size of the container.

Return
the size of the container.

std::pair<iterator, bool> insert(const value_type &value)
iterator insert(const_iterator it, const value_type &value)

Inserts an element into the container, if the container does not already contain an element with an equivalent key.

Return
an iterator to the inserted element (or to the element that prevented the insertion).
Parameters
  • value: The value to be inserted.