Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::MapOpenHash< Key, Data, Cmp, HashTable > Struct Template Reference

Open addressing hash map for key-value pairs. More...

#include <tpl_dynMapOhash.H>

Inheritance diagram for Aleph::MapOpenHash< Key, Data, Cmp, HashTable >:
[legend]
Collaboration diagram for Aleph::MapOpenHash< Key, Data, Cmp, HashTable >:
[legend]

Public Types

using Pair = std::pair< Key, Data >
 The key-value pair type stored in the map.
 
using Base = HashTable< std::pair< Key, Data >, Dft_Pair_Cmp< Key, Data, Cmp > >
 The base hash table type.
 
using Hash_Fct = std::function< size_t(const Key &)>
 Function type for hash functions.
 
using Hash_Fct_Ptr = size_t(*)(const Key &)
 Function pointer type for hash functions.
 
using Key_Type = Key
 The type of keys in the map.
 
using Data_Type = Data
 The type of mapped values.
 
using Value_Type = Data
 Alias for Data_Type (compatibility with other containers).
 
using Item_Type = Pair
 The item type stored in the map (key-value pair).
 
using Set_Type = MapOpenHash
 Self-reference type for generic programming.
 
using Iterator = typename Base::Iterator
 Iterator type for traversing the map.
 

Public Member Functions

 MapOpenHash (size_t len=Primes::DefaultPrime, Hash_Fct_Ptr first_hash_fct=dft_hash_fct< Key >, Hash_Fct_Ptr second_hash_fct=snd_hash_fct< Key >, Cmp cmp=Cmp(), float lower_alpha=hash_default_lower_alpha, float upper_alpha=hash_default_upper_alpha, bool with_resize=true)
 Construct a map with specified parameters.
 
Pairinsert (const Key &key, const Data &data)
 Insert a key-value pair (copy semantics).
 
Pairinsert (const Key &key, Data &&data)
 Insert a key-value pair (move data).
 
Pairinsert (Key &&key, Data &&data)
 Insert a key-value pair (move both).
 
Pairinsert (Key &&key, const Data &data)
 Insert a key-value pair (move key, copy data).
 
Pairsearch (const Key &key) const noexcept
 Search for a key in the map.
 
Pairsearch (Key &&key) const noexcept
 Search for a key in the map (move semantics).
 
bool has (const Key &key) const noexcept
 Check if a key exists in the map.
 
bool has (Key &&key) const noexcept
 Check if a key exists in the map (move semantics).
 
bool contains (const Key &key) const noexcept
 Check if a key exists in the map.
 
bool contains (Key &&key) const noexcept
 Check if a key exists in the map (move semantics).
 
Datafind (const Key &key)
 Find and return the value for a key.
 
Datafind (Key &&key)
 Find and return the value for a key (move semantics).
 
const Datafind (const Key &key) const
 Find and return the value for a key (const).
 
const Datafind (Key &&key) const
 Find and return the value for a key (const, move).
 
Dataoperator[] (const Key &key)
 Access or insert a value by key.
 
const Dataoperator[] (const Key &key) const
 Access value by key (const version).
 
Dataoperator[] (Key &&key)
 Access or insert a value by key (move semantics).
 
const Dataoperator[] (Key &&key) const
 Access value by key (const, move).
 
void remove_by_data (Data &data)
 Remove an entry by its data pointer.
 
void remove (const Key &key)
 Remove an entry by key.
 
void remove (Key &&key)
 Remove an entry by key (move semantics).
 
DynList< Key > keys () const
 Get a list of all keys in the map.
 
DynList< Datavalues () const
 Get a list of all values in the map.
 
DynList< Data * > values_ptr ()
 Get a list of pointers to all values.
 
DynList< Pair * > items_ptr ()
 Get a list of pointers to all pairs.
 

Static Public Member Functions

static Pairkey_to_pair (Key *ptr) noexcept
 Convert a key pointer to its containing pair pointer.
 
static const Pairkey_to_pair (const Key *ptr) noexcept
 
static Pairdata_to_pair (Data *ptr) noexcept
 Convert a data pointer to its containing pair pointer.
 
static const Pairdata_to_pair (const Data *ptr) noexcept
 
static Dataget_data (Key &key) noexcept
 Get the data associated with a key by reference.
 
static const Dataget_data (const Key &key) noexcept
 
static const Key & get_key (Data *data_ptr) noexcept
 Get the key associated with a data pointer.
 
static const Key & get_key (const Data *data_ptr) noexcept
 

Detailed Description

template<typename Key, typename Data, class Cmp = Aleph::equal_to<Key>, template< typename, class > class HashTable = ODhashTable>
struct Aleph::MapOpenHash< Key, Data, Cmp, HashTable >

Open addressing hash map for key-value pairs.

MapOpenHash<Key, Data, Cmp, HashTable> implements an associative container that maps keys to values using open addressing hash tables. It provides O(1) average-case complexity for insert, search, and delete operations.

Features

Example Usage

// Create a map with string keys and int values
// Insert elements
ages.insert("Alice", 30);
ages["Bob"] = 25;
// Search and access
if (ages.has("Alice"))
std::cout << "Alice's age: " << ages["Alice"] << '\n';
// Iterate
ages.traverse([](auto& pair) {
std::cout << pair.first << ": " << pair.second << '\n';
return true;
});
// Remove
ages.remove("Bob");
T & insert(const T &item)
Insert a new item by copy.
Definition htlist.H:1502
T remove()
Remove the first item of the list.
Definition htlist.H:1611
std::pair< First, Second > pair
Alias to std::pair kept for backwards compatibility.
Definition ahPair.H:89
DynList< T > maps(const C &c, Op op)
Classic map operation.
Open addressing hash map using double hashing.
bool traverse(Operation &operation) noexcept(traverse_is_noexcept< Operation >())
Traverse the container via its iterator and performs a conditioned operation on each item.
Definition ah-dry.H:95

Hash Table Variants

  • MapODhash: Uses double hashing (better distribution, more complex)
  • MapOLhash: Uses linear probing (simpler, better cache locality)

Thread Safety

This class is not thread-safe. External synchronization is required for concurrent access from multiple threads.

Template Parameters
KeyType of keys. Must be hashable and equality-comparable.
DataType of mapped values.
CmpEquality comparator for keys (default: Aleph::equal_to<Key>).
HashTableUnderlying hash table type (default: ODhashTable).
See also
MapODhash Double hashing variant
MapOLhash Linear probing variant
ODhashTable Underlying double hashing table
OLhashTable Underlying linear probing table

Definition at line 116 of file tpl_dynMapOhash.H.

Member Typedef Documentation

◆ Base

template<typename Key , typename Data , class Cmp = Aleph::equal_to<Key>, template< typename, class > class HashTable = ODhashTable>
using Aleph::MapOpenHash< Key, Data, Cmp, HashTable >::Base = HashTable<std::pair<Key, Data>, Dft_Pair_Cmp<Key, Data, Cmp> >

The base hash table type.

Definition at line 123 of file tpl_dynMapOhash.H.

◆ Data_Type

template<typename Key , typename Data , class Cmp = Aleph::equal_to<Key>, template< typename, class > class HashTable = ODhashTable>
using Aleph::MapOpenHash< Key, Data, Cmp, HashTable >::Data_Type = Data

The type of mapped values.

Definition at line 138 of file tpl_dynMapOhash.H.

◆ Hash_Fct

template<typename Key , typename Data , class Cmp = Aleph::equal_to<Key>, template< typename, class > class HashTable = ODhashTable>
using Aleph::MapOpenHash< Key, Data, Cmp, HashTable >::Hash_Fct = std::function<size_t(const Key &)>

Function type for hash functions.

Definition at line 129 of file tpl_dynMapOhash.H.

◆ Hash_Fct_Ptr

template<typename Key , typename Data , class Cmp = Aleph::equal_to<Key>, template< typename, class > class HashTable = ODhashTable>
using Aleph::MapOpenHash< Key, Data, Cmp, HashTable >::Hash_Fct_Ptr = size_t (*) (const Key &)

Function pointer type for hash functions.

Definition at line 132 of file tpl_dynMapOhash.H.

◆ Item_Type

template<typename Key , typename Data , class Cmp = Aleph::equal_to<Key>, template< typename, class > class HashTable = ODhashTable>
using Aleph::MapOpenHash< Key, Data, Cmp, HashTable >::Item_Type = Pair

The item type stored in the map (key-value pair).

Definition at line 144 of file tpl_dynMapOhash.H.

◆ Iterator

template<typename Key , typename Data , class Cmp = Aleph::equal_to<Key>, template< typename, class > class HashTable = ODhashTable>
using Aleph::MapOpenHash< Key, Data, Cmp, HashTable >::Iterator = typename Base::Iterator

Iterator type for traversing the map.

Definition at line 524 of file tpl_dynMapOhash.H.

◆ Key_Type

template<typename Key , typename Data , class Cmp = Aleph::equal_to<Key>, template< typename, class > class HashTable = ODhashTable>
using Aleph::MapOpenHash< Key, Data, Cmp, HashTable >::Key_Type = Key

The type of keys in the map.

Definition at line 135 of file tpl_dynMapOhash.H.

◆ Pair

template<typename Key , typename Data , class Cmp = Aleph::equal_to<Key>, template< typename, class > class HashTable = ODhashTable>
using Aleph::MapOpenHash< Key, Data, Cmp, HashTable >::Pair = std::pair<Key, Data>

The key-value pair type stored in the map.

Definition at line 120 of file tpl_dynMapOhash.H.

◆ Set_Type

template<typename Key , typename Data , class Cmp = Aleph::equal_to<Key>, template< typename, class > class HashTable = ODhashTable>
using Aleph::MapOpenHash< Key, Data, Cmp, HashTable >::Set_Type = MapOpenHash

Self-reference type for generic programming.

Definition at line 147 of file tpl_dynMapOhash.H.

◆ Value_Type

template<typename Key , typename Data , class Cmp = Aleph::equal_to<Key>, template< typename, class > class HashTable = ODhashTable>
using Aleph::MapOpenHash< Key, Data, Cmp, HashTable >::Value_Type = Data

Alias for Data_Type (compatibility with other containers).

Definition at line 141 of file tpl_dynMapOhash.H.

Constructor & Destructor Documentation

◆ MapOpenHash()

template<typename Key , typename Data , class Cmp = Aleph::equal_to<Key>, template< typename, class > class HashTable = ODhashTable>
Aleph::MapOpenHash< Key, Data, Cmp, HashTable >::MapOpenHash ( size_t  len = Primes::DefaultPrime,
Hash_Fct_Ptr  first_hash_fct = dft_hash_fct<Key>,
Hash_Fct_Ptr  second_hash_fct = snd_hash_fct<Key>,
Cmp  cmp = Cmp(),
float  lower_alpha = hash_default_lower_alpha,
float  upper_alpha = hash_default_upper_alpha,
bool  with_resize = true 
)
inline

Construct a map with specified parameters.

Parameters
[in]lenInitial table size (default: DefaultPrime).
[in]first_hash_fctPrimary hash function.
[in]second_hash_fctSecondary hash function (for double hashing).
[in]cmpEquality comparator for keys.
[in]lower_alphaLower load factor threshold for shrinking.
[in]upper_alphaUpper load factor threshold for growing.
[in]with_resizeEnable automatic resizing.
Exceptions
std::bad_allocIf memory allocation fails.

Definition at line 161 of file tpl_dynMapOhash.H.

Member Function Documentation

◆ contains() [1/2]

template<typename Key , typename Data , class Cmp = Aleph::equal_to<Key>, template< typename, class > class HashTable = ODhashTable>
bool Aleph::MapOpenHash< Key, Data, Cmp, HashTable >::contains ( const Key &  key) const
inlinenoexcept

Check if a key exists in the map.

Alias for has().

Parameters
[in]keyThe key to check.
Returns
true if the key exists, false otherwise.

Definition at line 359 of file tpl_dynMapOhash.H.

References Aleph::MapOpenHash< Key, Data, Cmp, HashTable >::has().

◆ contains() [2/2]

template<typename Key , typename Data , class Cmp = Aleph::equal_to<Key>, template< typename, class > class HashTable = ODhashTable>
bool Aleph::MapOpenHash< Key, Data, Cmp, HashTable >::contains ( Key &&  key) const
inlinenoexcept

Check if a key exists in the map (move semantics).

Parameters
[in]keyThe key to check.
Returns
true if the key exists, false otherwise.

Definition at line 369 of file tpl_dynMapOhash.H.

References Aleph::MapOpenHash< Key, Data, Cmp, HashTable >::has().

◆ data_to_pair() [1/2]

template<typename Key , typename Data , class Cmp = Aleph::equal_to<Key>, template< typename, class > class HashTable = ODhashTable>
static const Pair * Aleph::MapOpenHash< Key, Data, Cmp, HashTable >::data_to_pair ( const Data ptr)
inlinestaticnoexcept

Definition at line 212 of file tpl_dynMapOhash.H.

References Aleph::maps().

◆ data_to_pair() [2/2]

template<typename Key , typename Data , class Cmp = Aleph::equal_to<Key>, template< typename, class > class HashTable = ODhashTable>
static Pair * Aleph::MapOpenHash< Key, Data, Cmp, HashTable >::data_to_pair ( Data ptr)
inlinestaticnoexcept

Convert a data pointer to its containing pair pointer.

Given a pointer to the data (second) member of a pair, returns a pointer to the enclosing pair.

Parameters
[in]ptrPointer to data within a pair.
Returns
Pointer to the containing pair.
Warning
Only valid for pointers obtained from pairs in this map.

Definition at line 206 of file tpl_dynMapOhash.H.

References Aleph::maps().

Referenced by Aleph::MapOpenHash< Key, Data, Cmp, HashTable >::get_key(), Aleph::MapOpenHash< Key, Data, Cmp, HashTable >::get_key(), and Aleph::MapOpenHash< Key, Data, Cmp, HashTable >::remove_by_data().

◆ find() [1/4]

template<typename Key , typename Data , class Cmp = Aleph::equal_to<Key>, template< typename, class > class HashTable = ODhashTable>
Data & Aleph::MapOpenHash< Key, Data, Cmp, HashTable >::find ( const Key &  key)
inline

Find and return the value for a key.

Parameters
[in]keyThe key to find.
Returns
Reference to the associated value.
Exceptions
std::domain_errorIf the key is not found.

Definition at line 381 of file tpl_dynMapOhash.H.

References Aleph::maps().

Referenced by Aleph::MapOpenHash< Key, Data, Cmp, HashTable >::operator[](), and Aleph::MapOpenHash< Key, Data, Cmp, HashTable >::operator[]().

◆ find() [2/4]

template<typename Key , typename Data , class Cmp = Aleph::equal_to<Key>, template< typename, class > class HashTable = ODhashTable>
const Data & Aleph::MapOpenHash< Key, Data, Cmp, HashTable >::find ( const Key &  key) const
inline

Find and return the value for a key (const).

Parameters
[in]keyThe key to find.
Returns
Const reference to the associated value.
Exceptions
std::domain_errorIf the key is not found.

Definition at line 409 of file tpl_dynMapOhash.H.

References Aleph::maps().

◆ find() [3/4]

template<typename Key , typename Data , class Cmp = Aleph::equal_to<Key>, template< typename, class > class HashTable = ODhashTable>
Data & Aleph::MapOpenHash< Key, Data, Cmp, HashTable >::find ( Key &&  key)
inline

Find and return the value for a key (move semantics).

Parameters
[in]keyThe key to find.
Returns
Reference to the associated value.
Exceptions
std::domain_errorIf the key is not found.

Definition at line 395 of file tpl_dynMapOhash.H.

References Aleph::maps().

◆ find() [4/4]

template<typename Key , typename Data , class Cmp = Aleph::equal_to<Key>, template< typename, class > class HashTable = ODhashTable>
const Data & Aleph::MapOpenHash< Key, Data, Cmp, HashTable >::find ( Key &&  key) const
inline

Find and return the value for a key (const, move).

Parameters
[in]keyThe key to find.
Returns
Const reference to the associated value.
Exceptions
std::domain_errorIf the key is not found.

Definition at line 423 of file tpl_dynMapOhash.H.

References Aleph::maps().

◆ get_data() [1/2]

template<typename Key , typename Data , class Cmp = Aleph::equal_to<Key>, template< typename, class > class HashTable = ODhashTable>
static const Data & Aleph::MapOpenHash< Key, Data, Cmp, HashTable >::get_data ( const Key &  key)
inlinestaticnoexcept

◆ get_data() [2/2]

template<typename Key , typename Data , class Cmp = Aleph::equal_to<Key>, template< typename, class > class HashTable = ODhashTable>
static Data & Aleph::MapOpenHash< Key, Data, Cmp, HashTable >::get_data ( Key &  key)
inlinestaticnoexcept

Get the data associated with a key by reference.

Given a reference to a key that is stored in the map, returns a reference to its associated data.

Parameters
[in]keyReference to a key within a stored pair.
Returns
Reference to the associated data.
Warning
Only valid for keys obtained from pairs in this map.

Definition at line 228 of file tpl_dynMapOhash.H.

References Aleph::MapOpenHash< Key, Data, Cmp, HashTable >::key_to_pair().

◆ get_key() [1/2]

template<typename Key , typename Data , class Cmp = Aleph::equal_to<Key>, template< typename, class > class HashTable = ODhashTable>
static const Key & Aleph::MapOpenHash< Key, Data, Cmp, HashTable >::get_key ( const Data data_ptr)
inlinestaticnoexcept

◆ get_key() [2/2]

template<typename Key , typename Data , class Cmp = Aleph::equal_to<Key>, template< typename, class > class HashTable = ODhashTable>
static const Key & Aleph::MapOpenHash< Key, Data, Cmp, HashTable >::get_key ( Data data_ptr)
inlinestaticnoexcept

Get the key associated with a data pointer.

Given a pointer to data stored in the map, returns a reference to its associated key.

Parameters
[in]data_ptrPointer to data within a stored pair.
Returns
Reference to the associated key.
Warning
Only valid for data pointers obtained from this map.

Definition at line 248 of file tpl_dynMapOhash.H.

References Aleph::MapOpenHash< Key, Data, Cmp, HashTable >::data_to_pair().

◆ has() [1/2]

template<typename Key , typename Data , class Cmp = Aleph::equal_to<Key>, template< typename, class > class HashTable = ODhashTable>
bool Aleph::MapOpenHash< Key, Data, Cmp, HashTable >::has ( const Key &  key) const
inlinenoexcept

Check if a key exists in the map.

Parameters
[in]keyThe key to check.
Returns
true if the key exists, false otherwise.

Definition at line 337 of file tpl_dynMapOhash.H.

References Aleph::MapOpenHash< Key, Data, Cmp, HashTable >::search().

Referenced by Aleph::MapOpenHash< Key, Data, Cmp, HashTable >::contains(), Aleph::MapOpenHash< Key, Data, Cmp, HashTable >::contains(), TEST(), TEST(), TEST(), TEST(), and TEST().

◆ has() [2/2]

template<typename Key , typename Data , class Cmp = Aleph::equal_to<Key>, template< typename, class > class HashTable = ODhashTable>
bool Aleph::MapOpenHash< Key, Data, Cmp, HashTable >::has ( Key &&  key) const
inlinenoexcept

Check if a key exists in the map (move semantics).

Parameters
[in]keyThe key to check.
Returns
true if the key exists, false otherwise.

Definition at line 347 of file tpl_dynMapOhash.H.

References Aleph::MapOpenHash< Key, Data, Cmp, HashTable >::search().

◆ insert() [1/4]

template<typename Key , typename Data , class Cmp = Aleph::equal_to<Key>, template< typename, class > class HashTable = ODhashTable>
Pair * Aleph::MapOpenHash< Key, Data, Cmp, HashTable >::insert ( const Key &  key,
const Data data 
)
inline

Insert a key-value pair (copy semantics).

Inserts a new key-value pair into the map. If the key already exists, no insertion occurs.

Parameters
[in]keyThe key to insert.
[in]dataThe value to associate with the key.
Returns
Pointer to the inserted pair, or nullptr if key exists.
Exceptions
std::bad_allocIf memory allocation fails during resize.

Definition at line 269 of file tpl_dynMapOhash.H.

Referenced by MapODhashTest::populate_int_map(), MapODhashTest::populate_map(), MapOLhashTest::populate_map(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().

◆ insert() [2/4]

template<typename Key , typename Data , class Cmp = Aleph::equal_to<Key>, template< typename, class > class HashTable = ODhashTable>
Pair * Aleph::MapOpenHash< Key, Data, Cmp, HashTable >::insert ( const Key &  key,
Data &&  data 
)
inline

Insert a key-value pair (move data).

Parameters
[in]keyThe key to insert.
[in]dataThe value to move into the map.
Returns
Pointer to the inserted pair, or nullptr if key exists.

Definition at line 280 of file tpl_dynMapOhash.H.

◆ insert() [3/4]

template<typename Key , typename Data , class Cmp = Aleph::equal_to<Key>, template< typename, class > class HashTable = ODhashTable>
Pair * Aleph::MapOpenHash< Key, Data, Cmp, HashTable >::insert ( Key &&  key,
const Data data 
)
inline

Insert a key-value pair (move key, copy data).

Parameters
[in]keyThe key to move into the map.
[in]dataThe value to copy into the map.
Returns
Pointer to the inserted pair, or nullptr if key exists.

Definition at line 303 of file tpl_dynMapOhash.H.

◆ insert() [4/4]

template<typename Key , typename Data , class Cmp = Aleph::equal_to<Key>, template< typename, class > class HashTable = ODhashTable>
Pair * Aleph::MapOpenHash< Key, Data, Cmp, HashTable >::insert ( Key &&  key,
Data &&  data 
)
inline

Insert a key-value pair (move both).

Parameters
[in]keyThe key to move into the map.
[in]dataThe value to move into the map.
Returns
Pointer to the inserted pair, or nullptr if key exists.

Definition at line 291 of file tpl_dynMapOhash.H.

◆ items_ptr()

template<typename Key , typename Data , class Cmp = Aleph::equal_to<Key>, template< typename, class > class HashTable = ODhashTable>
DynList< Pair * > Aleph::MapOpenHash< Key, Data, Cmp, HashTable >::items_ptr ( )
inline

Get a list of pointers to all pairs.

Returns
DynList containing pointers to all pairs in the map.
Note
The pointers remain valid until the map is modified.

Definition at line 564 of file tpl_dynMapOhash.H.

References Aleph::DynList< T >::append(), and Aleph::maps().

◆ key_to_pair() [1/2]

template<typename Key , typename Data , class Cmp = Aleph::equal_to<Key>, template< typename, class > class HashTable = ODhashTable>
static const Pair * Aleph::MapOpenHash< Key, Data, Cmp, HashTable >::key_to_pair ( const Key *  ptr)
inlinestaticnoexcept

Definition at line 191 of file tpl_dynMapOhash.H.

◆ key_to_pair() [2/2]

template<typename Key , typename Data , class Cmp = Aleph::equal_to<Key>, template< typename, class > class HashTable = ODhashTable>
static Pair * Aleph::MapOpenHash< Key, Data, Cmp, HashTable >::key_to_pair ( Key *  ptr)
inlinestaticnoexcept

Convert a key pointer to its containing pair pointer.

Given a pointer to the key member of a pair, returns a pointer to the enclosing pair. This relies on the fact that the key is the first member of std::pair.

Parameters
[in]ptrPointer to a key within a pair.
Returns
Pointer to the containing pair.
Warning
Only valid for pointers obtained from pairs in this map.

Definition at line 186 of file tpl_dynMapOhash.H.

Referenced by Aleph::MapOpenHash< Key, Data, Cmp, HashTable >::get_data(), and Aleph::MapOpenHash< Key, Data, Cmp, HashTable >::get_data().

◆ keys()

template<typename Key , typename Data , class Cmp = Aleph::equal_to<Key>, template< typename, class > class HashTable = ODhashTable>
DynList< Key > Aleph::MapOpenHash< Key, Data, Cmp, HashTable >::keys ( ) const
inline

Get a list of all keys in the map.

Returns
DynList containing copies of all keys.

Definition at line 530 of file tpl_dynMapOhash.H.

References Aleph::maps().

◆ operator[]() [1/4]

template<typename Key , typename Data , class Cmp = Aleph::equal_to<Key>, template< typename, class > class HashTable = ODhashTable>
Data & Aleph::MapOpenHash< Key, Data, Cmp, HashTable >::operator[] ( const Key &  key)
inline

Access or insert a value by key.

If the key exists, returns a reference to its value. If not, inserts a new pair with default-constructed value and returns a reference to it.

Parameters
[in]keyThe key to access or insert.
Returns
Reference to the value associated with the key.
Exceptions
std::bad_allocIf insertion requires memory allocation.

Definition at line 441 of file tpl_dynMapOhash.H.

References Aleph::maps().

◆ operator[]() [2/4]

template<typename Key , typename Data , class Cmp = Aleph::equal_to<Key>, template< typename, class > class HashTable = ODhashTable>
const Data & Aleph::MapOpenHash< Key, Data, Cmp, HashTable >::operator[] ( const Key &  key) const
inline

Access value by key (const version).

Parameters
[in]keyThe key to access.
Returns
Const reference to the value.
Exceptions
std::domain_errorIf the key is not found.

Definition at line 455 of file tpl_dynMapOhash.H.

References Aleph::MapOpenHash< Key, Data, Cmp, HashTable >::find().

◆ operator[]() [3/4]

template<typename Key , typename Data , class Cmp = Aleph::equal_to<Key>, template< typename, class > class HashTable = ODhashTable>
Data & Aleph::MapOpenHash< Key, Data, Cmp, HashTable >::operator[] ( Key &&  key)
inline

Access or insert a value by key (move semantics).

Parameters
[in]keyThe key to access or insert.
Returns
Reference to the value associated with the key.

Definition at line 465 of file tpl_dynMapOhash.H.

References Aleph::maps().

◆ operator[]() [4/4]

template<typename Key , typename Data , class Cmp = Aleph::equal_to<Key>, template< typename, class > class HashTable = ODhashTable>
const Data & Aleph::MapOpenHash< Key, Data, Cmp, HashTable >::operator[] ( Key &&  key) const
inline

Access value by key (const, move).

Parameters
[in]keyThe key to access.
Returns
Const reference to the value.
Exceptions
std::domain_errorIf the key is not found.

Definition at line 479 of file tpl_dynMapOhash.H.

References Aleph::MapOpenHash< Key, Data, Cmp, HashTable >::find().

◆ remove() [1/2]

template<typename Key , typename Data , class Cmp = Aleph::equal_to<Key>, template< typename, class > class HashTable = ODhashTable>
void Aleph::MapOpenHash< Key, Data, Cmp, HashTable >::remove ( const Key &  key)
inline

Remove an entry by key.

Parameters
[in]keyThe key to remove.
Exceptions
std::domain_errorIf the key is not found.

Definition at line 503 of file tpl_dynMapOhash.H.

References Aleph::maps().

Referenced by TEST(), and TEST().

◆ remove() [2/2]

template<typename Key , typename Data , class Cmp = Aleph::equal_to<Key>, template< typename, class > class HashTable = ODhashTable>
void Aleph::MapOpenHash< Key, Data, Cmp, HashTable >::remove ( Key &&  key)
inline

Remove an entry by key (move semantics).

Parameters
[in]keyThe key to remove.
Exceptions
std::domain_errorIf the key is not found.

Definition at line 516 of file tpl_dynMapOhash.H.

References Aleph::maps().

◆ remove_by_data()

template<typename Key , typename Data , class Cmp = Aleph::equal_to<Key>, template< typename, class > class HashTable = ODhashTable>
void Aleph::MapOpenHash< Key, Data, Cmp, HashTable >::remove_by_data ( Data data)
inline

Remove an entry by its data pointer.

Removes the key-value pair that contains the given data pointer.

Parameters
[in]dataReference to data within a stored pair.
Warning
Only valid for data references obtained from this map.

Definition at line 492 of file tpl_dynMapOhash.H.

References Aleph::MapOpenHash< Key, Data, Cmp, HashTable >::data_to_pair().

◆ search() [1/2]

template<typename Key , typename Data , class Cmp = Aleph::equal_to<Key>, template< typename, class > class HashTable = ODhashTable>
Pair * Aleph::MapOpenHash< Key, Data, Cmp, HashTable >::search ( const Key &  key) const
inlinenoexcept

Search for a key in the map.

Parameters
[in]keyThe key to search for.
Returns
Pointer to the pair if found, nullptr otherwise.

Definition at line 313 of file tpl_dynMapOhash.H.

References Aleph::maps().

Referenced by Aleph::MapOpenHash< Key, Data, Cmp, HashTable >::has(), and Aleph::MapOpenHash< Key, Data, Cmp, HashTable >::has().

◆ search() [2/2]

template<typename Key , typename Data , class Cmp = Aleph::equal_to<Key>, template< typename, class > class HashTable = ODhashTable>
Pair * Aleph::MapOpenHash< Key, Data, Cmp, HashTable >::search ( Key &&  key) const
inlinenoexcept

Search for a key in the map (move semantics).

Parameters
[in]keyThe key to search for.
Returns
Pointer to the pair if found, nullptr otherwise.

Definition at line 325 of file tpl_dynMapOhash.H.

References Aleph::maps().

◆ values()

template<typename Key , typename Data , class Cmp = Aleph::equal_to<Key>, template< typename, class > class HashTable = ODhashTable>
DynList< Data > Aleph::MapOpenHash< Key, Data, Cmp, HashTable >::values ( ) const
inline

Get a list of all values in the map.

Returns
DynList containing copies of all values.

Definition at line 539 of file tpl_dynMapOhash.H.

References Aleph::maps().

◆ values_ptr()

template<typename Key , typename Data , class Cmp = Aleph::equal_to<Key>, template< typename, class > class HashTable = ODhashTable>
DynList< Data * > Aleph::MapOpenHash< Key, Data, Cmp, HashTable >::values_ptr ( )
inline

Get a list of pointers to all values.

Returns
DynList containing pointers to all values in the map.
Note
The pointers remain valid until the map is modified.

Definition at line 550 of file tpl_dynMapOhash.H.

References Aleph::DynList< T >::append(), and Aleph::maps().


The documentation for this struct was generated from the following file: