![]() |
AlgoPlus v0.1.0
|
#include <hash_table.h>
Public Types | |
using | BucketType |
Public Member Functions | |
Iterator (BucketIterator start, BucketIterator end) | |
Construct a new Iterator object. | |
Iterator & | operator= (const std::unordered_map< size_t, std::list< std::pair< KeyType, ValueType > > > &bucket) |
operator = for hash table iterator class | |
Iterator & | operator++ () |
operator ++ for type Iterator | |
Iterator | operator++ (int) |
operator ++ for type Iterator | |
Iterator & | operator-- () |
operator – for type Iterator | |
Iterator | operator-- (int) |
operator – for type Iterator | |
bool | operator!= (const Iterator &it) const |
operator != for Type Iterator | |
std::pair< KeyType, ValueType > & | operator* () |
operator * for Type Iterator | |
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 () |
Friends | |
std::ostream & | operator<< (std::ostream &out, hash_table< KeyType, ValueType > &h) |
<< operator for hash_table class | |
Iterator class.
|
inlineexplicit |
Construct a new Iterator object.
bucket | the bucket list |
|
inline |
Copy constructor of the hash_table.
h | the hash table we want to copy |
|
inlineexplicit |
Construct a new hash table object.
v | the initializer vector |
|
inline |
Inserts a key-value pair into the hash table.
This function inserts a key-value pair into the hash table. If a pair with the same key already exists, it updates the value.
key | The key to insert. |
value | The value to insert. |
|
inline |
operator != for Type Iterator
it | the iterator we want to make the check |
|
inline |
operator * for Type Iterator
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Removes the key-value pair associated with the given key from the hash table.
This function removes the key-value pair associated with the given key from the hash table.
key | The key to remove. |
|
inline |
Retrieves the value associated with the given key.
key | The key to retrieve the value for. |
|
friend |
<< operator for hash_table class