Luna::UnorderedMap
An container that contains key-value pairs with unique keys using closed-addressing hashing algorithm.
template <typename _Kty, typename _Ty, typename _Hash, typename _KeyEqual, typename _Alloc>
class Luna::UnorderedMap
Remark
See remarks of HashMap for details.
Member functions
-
Constructs an empty map.
-
UnorderedMap(const allocator_type &alloc)
Constructs an empty map with an custom allocator.
-
UnorderedMap(const UnorderedMap &rhs)
Constructs a map by coping elements from another map.
-
UnorderedMap(const UnorderedMap &rhs, const allocator_type &alloc)
Constructs a map with an custom allocator and with elements copied from another map.
-
UnorderedMap(UnorderedMap &&rhs)
Constructs a map by moving elements from another map.
-
UnorderedMap(UnorderedMap &&rhs, const allocator_type &alloc)
Constructs a map with an custom allocator and with elements moved from another map.
-
UnorderedMap & operator=(const UnorderedMap &rhs)
Replaces elements of the map by coping elements from another map.
-
UnorderedMap & operator=(UnorderedMap &&rhs)
Replaces elements of the map by moving elements from another map.
-
Gets one iterator to the first element of the map.
-
Gets one constant iterator to the first element of the map.
-
Gets one constant iterator to the first element of the map.
-
Gets one iterator to the one past last element of the map.
-
Gets one constant iterator to the one past last element of the map.
-
Gets one constant iterator to the one past last element of the map.
-
Gets an iterator to the first element of the bucket with specified index.
-
const_local_iterator begin(usize n) const
Gets an constant iterator to the first element of the bucket with specified index.
-
const_local_iterator cbegin(usize n) const
Gets a constant iterator to the first element of the bucket with specified index.
-
Gets an iterator to the one-past-last element of the bucket with specified index.
-
const_local_iterator end(usize n) const
Gets a constant iterator to the one-past-last element of the bucket with specified index.
-
const_local_iterator cend(usize n) const
Gets a constant iterator to the one-past-last element of the bucket with specified index.
-
Checks whether this map is empty, that is, the size of this map is
0
. -
Gets the size of the map, that is, the number of elements in the map.
-
Gets the capacity of the map, that is, the number of elements the hash table can hold before expanding the hash table.
-
Gets the number of buckets of the map.
-
usize bucket_size(usize n) const
Gets the number of elements of the specified bucket.
-
usize bucket(const key_type &key) const
Gets the index of the bucket that stores the specified key.
-
Gets the load factor of the map, which can be computed by
(f32)size() / (f32)bucket_count()
. -
Gets the maximum load factor allowed for the map.
-
Sets the maximum load factor allowed for the map.
-
Removes all elements in the map.
-
Gets the hash function used by this map.
-
Gets the equality comparison function used by this map.
-
void rehash(usize new_buckets_count)
Changes the bucket count and rehashes all elements to insert them to the new buckets.
-
Expands the bucket buffer so that it can store at least
new_cap
elements without enpanding the bucket buffer again. -
iterator find(const key_type &key)
Finds the specified element in the map.
-
const_iterator find(const key_type &key) const
Finds the specified element in the map.
-
usize count(const key_type &key) const
Gets the number of elements whose key is equal to the specified key.
-
Pair< iterator, iterator > equal_range(const key_type &key)
Gets one pair of iterators specifying one range of elements whose keys are equal to the specified key.
-
Pair< const_iterator, const_iterator > equal_range(const key_type &key) const
Gets one pair of iterators specifying one range of elements whose keys are equal to the specified key.
-
bool contains(const key_type &key) const
Checks whether at least one element with the specified key exists.
-
Pair< iterator, bool > insert(const value_type &value)
Inserts the specified value to the map. The key is extracted from the value.
-
Pair< iterator, bool > insert(value_type &&value)
Inserts the specified value to the map. The key is extracted from the value.
-
insert_return_type insert(node_type &&node)
Inserts one node to the map.
-
Pair< iterator, bool > insert_or_assign(const key_type &key, _M &&value)
Assigns the value to the element with the specified key, or inserts the value pair to the map if such element is not found. The key is extracted from the value.
-
Pair< iterator, bool > insert_or_assign(key_type &&key, _M &&value)
Assigns the value to the element with the specified key, or inserts the value pair to the map if such element is not found. The key is extracted from the value.
-
Pair< iterator, bool > emplace(_Args &&... args)
Constructs one element directly in the map using the provided arguments.
-
iterator erase(const_iterator pos)
Removes one element from the map.
-
usize erase(const key_type &key)
Removes elements with the specified key from the map.
-
Swaps elements of this map with the specified map.
-
node_type extract(const_iterator pos)
Extracts one node from the map, so that it can be inserted to another map without any element copy or move operation.
-
allocator_type get_allocator() const
Gets the allocator used by this map.