template<typename Key, typename KeyID, is_key_adapter< Key, KeyID > KeyAdapter, is_hash< Key > Hash = std::hash<Key>, is_bucket< KeyID > Bucket = std::vector<std::pair<std::size_t, KeyID>>, is_allocator< Bucket > Allocator = std::allocator<Bucket>>
class koutil::container::hash_array< Key, KeyID, KeyAdapter, Hash, Bucket, Allocator >
A hash array with open addressing and linear probing.
- Template Parameters
-
Key | The key type. |
KeyID | The key ID type. |
KeyAdapter | The key adapter type. |
Hash | The hash function type. |
Bucket | The bucket type. |
Allocator | The allocator type. |
template<typename Key , typename KeyID , is_key_adapter< Key, KeyID > KeyAdapter, is_hash< Key > Hash = std::hash<Key>, is_bucket< KeyID > Bucket = std::vector<std::pair<std::size_t, KeyID>>, is_allocator< Bucket > Allocator = std::allocator<Bucket>>
Constructor with bucket count.
- Parameters
-
bucket_count | Number of buckets. |
template<typename Key , typename KeyID , is_key_adapter< Key, KeyID > KeyAdapter, is_hash< Key > Hash = std::hash<Key>, is_bucket< KeyID > Bucket = std::vector<std::pair<std::size_t, KeyID>>, is_allocator< Bucket > Allocator = std::allocator<Bucket>>
Get an iterator to the beginning of the hash_array.
- Returns
- iterator_t Iterator to the beginning.
template<typename Key , typename KeyID , is_key_adapter< Key, KeyID > KeyAdapter, is_hash< Key > Hash = std::hash<Key>, is_bucket< KeyID > Bucket = std::vector<std::pair<std::size_t, KeyID>>, is_allocator< Bucket > Allocator = std::allocator<Bucket>>
Get a constant iterator to the beginning of the hash_array.
- Returns
- const_iterator_t Constant iterator to the beginning.
template<typename Key , typename KeyID , is_key_adapter< Key, KeyID > KeyAdapter, is_hash< Key > Hash = std::hash<Key>, is_bucket< KeyID > Bucket = std::vector<std::pair<std::size_t, KeyID>>, is_allocator< Bucket > Allocator = std::allocator<Bucket>>
Returns the number of buckets.
- Returns
- std::size_t Number of buckets.
template<typename Key , typename KeyID , is_key_adapter< Key, KeyID > KeyAdapter, is_hash< Key > Hash = std::hash<Key>, is_bucket< KeyID > Bucket = std::vector<std::pair<std::size_t, KeyID>>, is_allocator< Bucket > Allocator = std::allocator<Bucket>>
Get a constant iterator to the beginning of the hash_array.
- Returns
- iterator_t Constant iterator to the beginning.
template<typename Key , typename KeyID , is_key_adapter< Key, KeyID > KeyAdapter, is_hash< Key > Hash = std::hash<Key>, is_bucket< KeyID > Bucket = std::vector<std::pair<std::size_t, KeyID>>, is_allocator< Bucket > Allocator = std::allocator<Bucket>>
Get a constant iterator to the end of the hash_array.
- Returns
- const_iterator_t Constant iterator to the end.
template<typename Key , typename KeyID , is_key_adapter< Key, KeyID > KeyAdapter, is_hash< Key > Hash = std::hash<Key>, is_bucket< KeyID > Bucket = std::vector<std::pair<std::size_t, KeyID>>, is_allocator< Bucket > Allocator = std::allocator<Bucket>>
template<typename Key , typename KeyID , is_key_adapter< Key, KeyID > KeyAdapter, is_hash< Key > Hash = std::hash<Key>, is_bucket< KeyID > Bucket = std::vector<std::pair<std::size_t, KeyID>>, is_allocator< Bucket > Allocator = std::allocator<Bucket>>
Check if the hash_array is empty.
- Returns
- bool True if empty, false otherwise.
template<typename Key , typename KeyID , is_key_adapter< Key, KeyID > KeyAdapter, is_hash< Key > Hash = std::hash<Key>, is_bucket< KeyID > Bucket = std::vector<std::pair<std::size_t, KeyID>>, is_allocator< Bucket > Allocator = std::allocator<Bucket>>
Get an iterator to the end of the hash_array.
- Returns
- iterator_t Iterator to the end.
template<typename Key , typename KeyID , is_key_adapter< Key, KeyID > KeyAdapter, is_hash< Key > Hash = std::hash<Key>, is_bucket< KeyID > Bucket = std::vector<std::pair<std::size_t, KeyID>>, is_allocator< Bucket > Allocator = std::allocator<Bucket>>
Get a constant iterator to the end of the hash_array.
- Returns
- const_iterator_t Constant iterator to the end.
template<typename Key , typename KeyID , is_key_adapter< Key, KeyID > KeyAdapter, is_hash< Key > Hash = std::hash<Key>, is_bucket< KeyID > Bucket = std::vector<std::pair<std::size_t, KeyID>>, is_allocator< Bucket > Allocator = std::allocator<Bucket>>
Erases an element from the hash table.
- Parameters
-
key | Key of the element to erase. |
adapter | Key adapter for comparison. |
- Returns
- true If the element was successfully erased.
-
false If the element was not found.
template<typename Key , typename KeyID , is_key_adapter< Key, KeyID > KeyAdapter, is_hash< Key > Hash = std::hash<Key>, is_bucket< KeyID > Bucket = std::vector<std::pair<std::size_t, KeyID>>, is_allocator< Bucket > Allocator = std::allocator<Bucket>>
Finds an element in the hash table.
- Parameters
-
key | Key of the element to find. |
adapter | Key adapter for comparison. |
- Returns
- iterator_t The iterator with found element, if not found end() is returned.
template<typename Key , typename KeyID , is_key_adapter< Key, KeyID > KeyAdapter, is_hash< Key > Hash = std::hash<Key>, is_bucket< KeyID > Bucket = std::vector<std::pair<std::size_t, KeyID>>, is_allocator< Bucket > Allocator = std::allocator<Bucket>>
Finds an element in the hash table.
- Parameters
-
key | Key of the element to find. |
adapter | Key adapter for comparison. |
- Returns
- const_iterator_t The iterator with found element, if not found end() is returned.
template<typename Key , typename KeyID , is_key_adapter< Key, KeyID > KeyAdapter, is_hash< Key > Hash = std::hash<Key>, is_bucket< KeyID > Bucket = std::vector<std::pair<std::size_t, KeyID>>, is_allocator< Bucket > Allocator = std::allocator<Bucket>>
Returns the maximum load factor.
- Returns
- float Maximum load factor.
template<typename Key , typename KeyID , is_key_adapter< Key, KeyID > KeyAdapter, is_hash< Key > Hash = std::hash<Key>, is_bucket< KeyID > Bucket = std::vector<std::pair<std::size_t, KeyID>>, is_allocator< Bucket > Allocator = std::allocator<Bucket>>
hash_array & koutil::container::hash_array< Key, KeyID, KeyAdapter, Hash, Bucket, Allocator >::operator= |
( |
const hash_array< Key, KeyID, KeyAdapter, Hash, Bucket, Allocator > & | other | ) |
|
|
default |
template<typename Key , typename KeyID , is_key_adapter< Key, KeyID > KeyAdapter, is_hash< Key > Hash = std::hash<Key>, is_bucket< KeyID > Bucket = std::vector<std::pair<std::size_t, KeyID>>, is_allocator< Bucket > Allocator = std::allocator<Bucket>>
hash_array & koutil::container::hash_array< Key, KeyID, KeyAdapter, Hash, Bucket, Allocator >::operator= |
( |
hash_array< Key, KeyID, KeyAdapter, Hash, Bucket, Allocator > && | other | ) |
|
|
default |
template<typename Key , typename KeyID , is_key_adapter< Key, KeyID > KeyAdapter, is_hash< Key > Hash = std::hash<Key>, is_bucket< KeyID > Bucket = std::vector<std::pair<std::size_t, KeyID>>, is_allocator< Bucket > Allocator = std::allocator<Bucket>>
Sets a new maximum load factor.
- Parameters
-
factor | New maximum load factor. |
template<typename Key , typename KeyID , is_key_adapter< Key, KeyID > KeyAdapter, is_hash< Key > Hash = std::hash<Key>, is_bucket< KeyID > Bucket = std::vector<std::pair<std::size_t, KeyID>>, is_allocator< Bucket > Allocator = std::allocator<Bucket>>
Get the number of elements in the hash_array.
- Returns
- std::size_t Number of elements.
template<typename Key , typename KeyID , is_key_adapter< Key, KeyID > KeyAdapter, is_hash< Key > Hash = std::hash<Key>, is_bucket< KeyID > Bucket = std::vector<std::pair<std::size_t, KeyID>>, is_allocator< Bucket > Allocator = std::allocator<Bucket>>
Try to insert a key and key ID into the hash_array.
- Parameters
-
key | The key to insert. |
key_id | The key ID to insert. |
- Returns
- bool True if the key is not inside hash_array, false otherwise.