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

Generic hash table with collision resolution by separate chaining and buckets without virtual destructor. More...

#include <tpl_lhash.H>

Inheritance diagram for Aleph::LhashTable< Key, Cmp >:
[legend]
Collaboration diagram for Aleph::LhashTable< Key, Cmp >:
[legend]

Public Types

using Base = GenLhashTable< Key, LhashBucket< Key >, Cmp >
 
- Public Types inherited from Aleph::GenLhashTable< Key, BucketType, Cmp >
using Bucket = BucketType
 
using Hash_Fct = std::function< size_t(const Key &)>
 
using Hash_Fct_Ptr = size_t(*)(const Key &)
 
using Key_Type = Key
 
using Item_Type = Key
 

Additional Inherited Members

- Public Member Functions inherited from Aleph::GenLhashTable< Key, BucketType, Cmp >
Cmp & get_compare ()
 
const Cmp & get_compare () const
 
 GenLhashTable (size_t table_size=Primes::DefaultPrime, Hash_Fct_Ptr hash_fct=Aleph::dft_hash_fct< Key >, Cmp cmp=Cmp(), float lower_alpha=hash_default_lower_alpha, float upper_alpha=hash_default_upper_alpha, bool remove_all_buckets=true, bool with_resize=true)
 Instantiate a generic hash table.
 
void swap (GenLhashTable &other) noexcept
 
 GenLhashTable (const GenLhashTable &)=delete
 
GenLhashTableoperator= (const GenLhashTable &)=delete
 
 GenLhashTable (GenLhashTable &&other) noexcept
 
GenLhashTableoperator= (GenLhashTable &&other) noexcept
 
void empty () noexcept
 Empties the hash table; frees memory of all buckets.
 
Hash_Fct get_hash_fct () const noexcept
 
void set_hash_fct (Hash_Fct fct) noexcept
 Set the internal hash function.
 
void set_hash_fct (Hash_Fct_Ptr fct) noexcept
 
float current_alpha () const noexcept
 return the current table load
 
Bucketinsert (Bucket *bucket)
 Inserts bucket into the table and returns its address if the key is not already in the table; otherwise returns nullptr.
 
Bucketsearch_or_insert (Bucket *bucket)
 
Bucketsearch (const Key &key) const noexcept
 Search in the table for a bucket with key.
 
Bucketremove (Bucket *bucket) noexcept
 Removes bucket from the table.
 
size_t resize (const size_t new_size)
 Resizes the hash table to new_size and re-locates keys.
 
virtual ~GenLhashTable ()
 Frees the table memory and, if remove_all_buckets is true (specified in the constructor), also frees memory of all buckets.
 
Bucketsearch_next (Bucket *bucket) const
 Returns the next bucket that collides with bucket.
 
const size_tcapacity () const noexcept
 Returns the table capacity.
 
const size_tsize () const noexcept
 Returns the number of elements contained in the table.
 
const size_tget_num_busy_slots () const noexcept
 Returns the number of occupied entries in the array.
 
constexpr bool is_empty () const noexcept
 
- Public Member Functions inherited from HashStats< GenLhashTable< Key, BucketType, Cmp > >
Stats stats () const
 Computes statistics about chain length distribution.
 
void print_stats (const Stats &stats) const
 Prints statistics to standard output.
 
void set_upper_alpha (float __upper_alpha)
 Sets the upper load factor threshold.
 
void set_lower_alpha (float __lower_alpha)
 Sets the lower load factor threshold.
 
constexpr float get_lower_alpha () const noexcept
 Returns the lower load factor threshold.
 
constexpr float get_upper_alpha () const noexcept
 Returns the upper load factor threshold.
 
- Protected Member Functions inherited from Aleph::GenLhashTable< Key, BucketType, Cmp >
 GenLhashTable (const size_t table_size, Hash_Fct hash_f, Cmp cpm_fct, const float lower, const float upper, const bool remove_all, const bool resize)
 
template<typename HashFunc , typename SearchKey >
Bucketsearch_with_custom_hash (HashFunc hash_func, const SearchKey &search_key) const noexcept
 Helper method for derived classes to perform custom heterogeneous searches.
 
- Protected Attributes inherited from Aleph::GenLhashTable< Key, BucketType, Cmp >
Hash_Fct hash_fct
 
size_t len
 
Cmp cmp
 
float lower_alpha
 
float upper_alpha
 

Detailed Description

template<typename Key, class Cmp = Aleph::equal_to<Key>>
struct Aleph::LhashTable< Key, Cmp >

Generic hash table with collision resolution by separate chaining and buckets without virtual destructor.

The LhashTable type implements a generic hash table with collision resolution by separate chaining where buckets do not have a virtual destructor.

Parameters
Keyindexing key type of the table.
Cmpkey comparison class; must return true if keys are equal.
See also
GenLhashTable LhashTableVtl

Definition at line 808 of file tpl_lhash.H.

Member Typedef Documentation

◆ Base

template<typename Key , class Cmp = Aleph::equal_to<Key>>
using Aleph::LhashTable< Key, Cmp >::Base = GenLhashTable<Key, LhashBucket<Key>, Cmp>

Definition at line 810 of file tpl_lhash.H.


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