44# ifndef TPL_DYNLHASH_H
45# define TPL_DYNLHASH_H
89 template <
typename Key,
typename Record,
class Cmp = Aleph::equal_to<Key>>
90 requires EqualityComparator<Cmp, Key>
125 char * addr =
reinterpret_cast<char *
>(rec);
146 <<
"access to unexisting entry";
166 <<
"access to unexisting entry";
314 if (taken ==
nullptr)
355 std::forward<Record>(record)));
368 return bucket !=
nullptr ? &bucket->
record :
nullptr;
C++20 concepts hub: comparison, BST policy, and Aleph container concepts.
Exception handling system with formatted messages for Aleph-w.
#define ah_invalid_argument_if(C)
Throws std::invalid_argument if condition holds.
DLProxy(DynLhashTable &_table, const Key &_key)
DLProxy & operator=(const Record &record)
Dynamic hash table mapping keys to records with separate chaining.
DynLhashTable(const DynLhashTable &table)
Copy constructor.
Record * search(const Key &key)
Search for a key in the table.
DLBucket * take(DLBucket *bucket)
DynLhashTable(DynLhashTable &&table) noexcept
Move constructor.
DynLhashTable(size_t len=DefaultPrime, Hash_Fct_Ptr hash_fct=dft_hash_ptr_fct< Key >)
Construct a dynamic hash table.
void copy(const DynLhashTable &table)
Record * insert(const Key &key, Record &&record=Record())
This is an overloaded member function, provided for convenience. It differs from the above function o...
typename Base::Hash_Fct_Ptr Hash_Fct_Ptr
The type of hash function pointer.
void remove(Record *record)
Remove an entry from the table.
LhashTableVtl< Key, Cmp > Base
Record * insert(Key &&key, const Record &record)
This is an overloaded member function, provided for convenience. It differs from the above function o...
DynLhashTable & operator=(const DynLhashTable &table)
Copy assignment operator.
Record * insert(Key &&key, Record &&record)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Record * __insert(DLBucket *bucket)
void swap(DynLhashTable &table) noexcept
Swap contents with another table.
DLProxy operator[](const Key &key) const
Access or insert an entry using subscript notation.
Record * insert(const Key &key, const Record &record)
Insert a key-record pair into the table.
static DLBucket * record_to_bucket(Record *rec)
Iterator over a GenLhashTable hash table.
bool has_curr() const noexcept
Returns true if the iterator has a current bucket.
Bucket * remove(Bucket *bucket) noexcept
Removes bucket from the table.
GenLhashTable & operator=(const GenLhashTable &)=delete
Bucket * insert(Bucket *bucket)
Inserts bucket into the table and returns its address if the key is not already in the table; otherwi...
Hash_Fct get_hash_fct() const noexcept
size_t(*)(const Key &) Hash_Fct_Ptr
const size_t & capacity() const noexcept
Returns the table capacity.
void swap(GenLhashTable &other) noexcept
Swaps this table with other in constant time.
Bucket * search(const Key &key) const noexcept
Search in the table for a bucket with key.
constexpr float get_upper_alpha() const noexcept
Returns the upper load factor threshold.
constexpr bool get_with_resize() const noexcept
Returns whether the table resizes itself.
constexpr float get_lower_alpha() const noexcept
Returns the lower load factor threshold.
void free_bucket_not_taken(Bucket *bucket) noexcept
Frees a bucket that a hash table of lists was given and did not take.
const long double offset[]
Offset values indexed by symbol string length (bounded by MAX_OFFSET_INDEX)
Main namespace for Aleph-w library functions.
const unsigned long DefaultPrime
Default prime number used when no specific size is requested.
DLBucket(Key &&key, const Record &_record)
DLBucket(Key &&key, Record &&_record)
DLBucket(const Key &key, Record &&_record)
DLBucket(const Key &key, const Record &_record)
Generic hash table with collision resolution by separate chaining and buckets with virtual destructor...
Hash tables with collision resolution by separate chaining.