|
| hash_table (std::vector< std::pair< KeyType, ValueType > > v={}) |
| Construct a new hash table object.
|
|
| hash_table (const hash_table &h) |
| Copy constructor of the hash_table.
|
|
hash_table & | operator= (const hash_table &h) |
| operator = for the hash_table class
|
|
| ~hash_table () |
| Destroy the hash table object.
|
|
void | insert (const KeyType &key, const ValueType &value) |
| Inserts a key-value pair into the hash table.
|
|
std::optional< ValueType > | retrieve (const KeyType &key) |
| Retrieves the value associated with the given key.
|
|
void | remove (const KeyType &key) |
| Removes the key-value pair associated with the given key from the hash table.
|
|
Iterator | begin () |
|
Iterator | end () |
|
template<typename KeyType, typename ValueType>
class hash_table< KeyType, ValueType >
A simple implementation of a hash table.
- Template Parameters
-
KeyType | Type of the keys in the hash table. |
ValueType | Type of the values in the hash table. |
This is a templated class for a hash table, a data structure that provides fast data retrieval and storage operations based on keys. The template parameters are the type of the keys and the type of the values stored in the hash table. Keys cannot be duplicate and an insertion of an existing key leads to an update of the corresponding value.
The following are the class methods
- Note
- Use only types that can be hashed as the KeyType.