|
Tkrzw
|
Doubly-linked hash map. More...
#include <tkrzw_containers.h>
Classes | |
| class | ConstIterator |
| Const iterator of records. More... | |
| class | Iterator |
| Iterator of records. More... | |
| struct | Record |
| Record data. More... | |
Public Types | |
| enum | MoveMode : int32_t { MOVE_CURRENT = 0 , MOVE_FIRST = 1 , MOVE_LAST = 2 } |
| Enumeration for move modes. More... | |
Public Member Functions | |
| LinkedHashMap () | |
| Default constructor. More... | |
| LinkedHashMap (size_t num_buckets) | |
| Constructor. More... | |
| ~LinkedHashMap () | |
| Destructor. More... | |
| LinkedHashMap (const LinkedHashMap &rhs)=delete | |
| Copy and assignment are disabled. More... | |
| LinkedHashMap & | operator= (const LinkedHashMap &rhs)=delete |
| Record * | Get (const KEYTYPE &key, MoveMode mode=MOVE_CURRENT) |
| Retrieves a record. More... | |
| VALUETYPE | GetSimple (const KEYTYPE &key, VALUETYPE default_value=VALUETYPE(), MoveMode mode=MOVE_CURRENT) |
| Retrieves a record. More... | |
| Record * | Set (const KEYTYPE &key, const VALUETYPE &value, bool overwrite=true, MoveMode mode=MOVE_CURRENT) |
| Stores a record. More... | |
| bool | Remove (const KEYTYPE &key) |
| Removes a record. More... | |
| Record * | Migrate (const KEYTYPE &key, LinkedHashMap *dest, MoveMode mode) |
| Migrates a record to another map. More... | |
| void | clear () |
| Removes all records. More... | |
| size_t | size () const |
| Gets the number of records. More... | |
| bool | empty () const |
| Checks whether no records exist. More... | |
| Iterator | begin () |
| Gets an iterator at the first record. More... | |
| ConstIterator | begin () const |
| Gets a const iterator at the first record. More... | |
| Iterator | end () |
| Gets an iterator of the end sentry. More... | |
| ConstIterator | end () const |
| Gets a const iterator of the end sentry. More... | |
| Iterator | find (const KEYTYPE &key) |
| Gets an iterator at a record. More... | |
| ConstIterator | find (const KEYTYPE &key) const |
| Gets an iterator at a record. More... | |
| VALUETYPE & | operator[] (const KEYTYPE &key) |
| Refers to a record. More... | |
| std::pair< Iterator, bool > | insert (const Record &record) |
| Insert a record without overwriting an existing record. More... | |
| size_t | erase (const KEYTYPE &key) |
| Removes a record. More... | |
| Record & | front () |
| Gets the reference of the first record. More... | |
| const Record & | front () const |
| Gets the reference of the first record. More... | |
| Record & | back () |
| Gets the reference of the last record. More... | |
| const Record & | back () const |
| Gets the reference of the last record. More... | |
| void | rehash (size_t num_buckets) |
| Rehashes all records to a new number of records. More... | |
| float | load_factor () const |
| Gets average number of elements per bucket. More... | |
Static Public Attributes | |
| static constexpr size_t | DEFAULT_NUM_BUCKETS = 101 |
| The default value of the number of buckets. More... | |
Doubly-linked hash map.
| KEYTYPE | the key type. |
| VALUETYPE | the value type. |
| HASHTYPE | the hash functor. |
| EQUALTOTYPE | the equality checking functor. |
| enum tkrzw::LinkedHashMap::MoveMode : int32_t |
| tkrzw::LinkedHashMap< KEYTYPE, VALUETYPE, HASHTYPE, EQUALTOTYPE >::LinkedHashMap |
Default constructor.
|
explicit |
Constructor.
| num_buckets | The number of buckets of the hash table. |
| tkrzw::LinkedHashMap< KEYTYPE, VALUETYPE, HASHTYPE, EQUALTOTYPE >::~LinkedHashMap |
Destructor.
|
explicitdelete |
Copy and assignment are disabled.
| LinkedHashMap< KEYTYPE, VALUETYPE, HASHTYPE, EQUALTOTYPE >::Record * tkrzw::LinkedHashMap< KEYTYPE, VALUETYPE, HASHTYPE, EQUALTOTYPE >::Get | ( | const KEYTYPE & | key, |
| MoveMode | mode = MOVE_CURRENT |
||
| ) |
Retrieves a record.
| key | The key. |
| mode | The moving mode. |
| VALUETYPE tkrzw::LinkedHashMap< KEYTYPE, VALUETYPE, HASHTYPE, EQUALTOTYPE >::GetSimple | ( | const KEYTYPE & | key, |
| VALUETYPE | default_value = VALUETYPE(), |
||
| MoveMode | mode = MOVE_CURRENT |
||
| ) |
Retrieves a record.
| key | The key. |
| default_value | The value to be returned on failure. |
| mode | The moving mode. |
| LinkedHashMap< KEYTYPE, VALUETYPE, HASHTYPE, EQUALTOTYPE >::Record * tkrzw::LinkedHashMap< KEYTYPE, VALUETYPE, HASHTYPE, EQUALTOTYPE >::Set | ( | const KEYTYPE & | key, |
| const VALUETYPE & | value, | ||
| bool | overwrite = true, |
||
| MoveMode | mode = MOVE_CURRENT |
||
| ) |
Stores a record.
| key | The key. |
| value | The value. |
| mode | The moving mode. |
| overwrite | Whether to overwrite the existing value. |
| bool tkrzw::LinkedHashMap< KEYTYPE, VALUETYPE, HASHTYPE, EQUALTOTYPE >::Remove | ( | const KEYTYPE & | key | ) |
Removes a record.
| key | The key. |
| LinkedHashMap< KEYTYPE, VALUETYPE, HASHTYPE, EQUALTOTYPE >::Record * tkrzw::LinkedHashMap< KEYTYPE, VALUETYPE, HASHTYPE, EQUALTOTYPE >::Migrate | ( | const KEYTYPE & | key, |
| LinkedHashMap< KEYTYPE, VALUETYPE, HASHTYPE, EQUALTOTYPE > * | dest, | ||
| MoveMode | mode | ||
| ) |
Migrates a record to another map.
| key | The key. |
| dest | The destination map. |
| mode | The moving mode. |
| void tkrzw::LinkedHashMap< KEYTYPE, VALUETYPE, HASHTYPE, EQUALTOTYPE >::clear |
Removes all records.
| size_t tkrzw::LinkedHashMap< KEYTYPE, VALUETYPE, HASHTYPE, EQUALTOTYPE >::size |
Gets the number of records.
| bool tkrzw::LinkedHashMap< KEYTYPE, VALUETYPE, HASHTYPE, EQUALTOTYPE >::empty |
Checks whether no records exist.
| LinkedHashMap< KEYTYPE, VALUETYPE, HASHTYPE, EQUALTOTYPE >::Iterator tkrzw::LinkedHashMap< KEYTYPE, VALUETYPE, HASHTYPE, EQUALTOTYPE >::begin |
Gets an iterator at the first record.
| LinkedHashMap< KEYTYPE, VALUETYPE, HASHTYPE, EQUALTOTYPE >::ConstIterator tkrzw::LinkedHashMap< KEYTYPE, VALUETYPE, HASHTYPE, EQUALTOTYPE >::begin |
Gets a const iterator at the first record.
| LinkedHashMap< KEYTYPE, VALUETYPE, HASHTYPE, EQUALTOTYPE >::Iterator tkrzw::LinkedHashMap< KEYTYPE, VALUETYPE, HASHTYPE, EQUALTOTYPE >::end |
Gets an iterator of the end sentry.
| LinkedHashMap< KEYTYPE, VALUETYPE, HASHTYPE, EQUALTOTYPE >::ConstIterator tkrzw::LinkedHashMap< KEYTYPE, VALUETYPE, HASHTYPE, EQUALTOTYPE >::end |
Gets a const iterator of the end sentry.
| LinkedHashMap< KEYTYPE, VALUETYPE, HASHTYPE, EQUALTOTYPE >::Iterator tkrzw::LinkedHashMap< KEYTYPE, VALUETYPE, HASHTYPE, EQUALTOTYPE >::find | ( | const KEYTYPE & | key | ) |
Gets an iterator at a record.
| key | The key of the record to find. |
| LinkedHashMap< KEYTYPE, VALUETYPE, HASHTYPE, EQUALTOTYPE >::ConstIterator tkrzw::LinkedHashMap< KEYTYPE, VALUETYPE, HASHTYPE, EQUALTOTYPE >::find | ( | const KEYTYPE & | key | ) | const |
Gets an iterator at a record.
| key | The key of the record to find. |
| VALUETYPE & tkrzw::LinkedHashMap< KEYTYPE, VALUETYPE, HASHTYPE, EQUALTOTYPE >::operator[] | ( | const KEYTYPE & | key | ) |
Refers to a record.
| key | The key of the record to find. |
If there's no matching record. a new record is created.
| std::pair< typename LinkedHashMap< KEYTYPE, VALUETYPE, HASHTYPE, EQUALTOTYPE >::Iterator, bool > tkrzw::LinkedHashMap< KEYTYPE, VALUETYPE, HASHTYPE, EQUALTOTYPE >::insert | ( | const Record & | record | ) |
Insert a record without overwriting an existing record.
| record | The record to insert. |
| size_t tkrzw::LinkedHashMap< KEYTYPE, VALUETYPE, HASHTYPE, EQUALTOTYPE >::erase | ( | const KEYTYPE & | key | ) |
Removes a record.
| key | The key. |
| LinkedHashMap< KEYTYPE, VALUETYPE, HASHTYPE, EQUALTOTYPE >::Record & tkrzw::LinkedHashMap< KEYTYPE, VALUETYPE, HASHTYPE, EQUALTOTYPE >::front |
Gets the reference of the first record.
| const LinkedHashMap< KEYTYPE, VALUETYPE, HASHTYPE, EQUALTOTYPE >::Record & tkrzw::LinkedHashMap< KEYTYPE, VALUETYPE, HASHTYPE, EQUALTOTYPE >::front |
Gets the reference of the first record.
| LinkedHashMap< KEYTYPE, VALUETYPE, HASHTYPE, EQUALTOTYPE >::Record & tkrzw::LinkedHashMap< KEYTYPE, VALUETYPE, HASHTYPE, EQUALTOTYPE >::back |
Gets the reference of the last record.
| const LinkedHashMap< KEYTYPE, VALUETYPE, HASHTYPE, EQUALTOTYPE >::Record & tkrzw::LinkedHashMap< KEYTYPE, VALUETYPE, HASHTYPE, EQUALTOTYPE >::back |
Gets the reference of the last record.
| void tkrzw::LinkedHashMap< KEYTYPE, VALUETYPE, HASHTYPE, EQUALTOTYPE >::rehash | ( | size_t | num_buckets | ) |
Rehashes all records to a new number of records.
| num_buckets | The new number of buckets. |
| float tkrzw::LinkedHashMap< KEYTYPE, VALUETYPE, HASHTYPE, EQUALTOTYPE >::load_factor |
Gets average number of elements per bucket.
|
staticconstexpr |
The default value of the number of buckets.