|
Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
|
Open addressing hash table with double hashing collision resolution. More...
#include <tpl_odhash.H>
Classes | |
| struct | Bucket |
Public Types | |
| enum | Status { EMPTY , BUSY , DELETED } |
| enum | Probe { NO_PROBED , FIRST_PROBE , SECOND_PROBE , LINEAR_PROBE } |
| using | Key_Type = Key |
| using | Item_Type = Key |
| using | Hash_Fct = std::function< size_t(const Key &)> |
| using | Hash_Fct_Ptr = size_t(*)(const Key &) |
| using | Base = OhashCommon< ODhashTable< Key, Cmp >, Key > |
| Instantiate a closed hash table with collision resolution by double hashing. | |
| using | Stats = typename OhashCommon< ODhashTable< Key, Cmp >, Key >::Stats |
Public Types inherited from OhashCommon< HashTbl, Key > | |
| using | Const_Iterator = Aleph::Const_Iterator< Iterator > |
| Read-only iterator: the iterator of a constant table. | |
Public Types inherited from StlAlephIterator< SetName > | |
| using | iterator = StlIterator< SetName > |
| using | const_iterator = StlConstIterator< SetName > |
Public Member Functions | |
| constexpr const Cmp & | get_compare () const noexcept |
| constexpr Cmp & | get_compare () noexcept |
| void | swap (ODhashTable &other) noexcept |
Swaps this table with other in constant time. | |
| ODhashTable (size_t len=Primes::DefaultPrime, Hash_Fct_Ptr first_hash_fct=Aleph::dft_hash_ptr_fct< Key >, Hash_Fct_Ptr second_hash_fct=Aleph::snd_hash_ptr_fct< Key >, Cmp cmp=Cmp(), float lower_alpha=hash_default_lower_alpha, float upper_alpha=hash_default_upper_alpha, bool with_resize=true) | |
| template<typename H1 , typename H2 > requires (std::is_convertible_v<H1, Hash_Fct_Ptr> and std::is_convertible_v<H2, Hash_Fct_Ptr> and (std::is_class_v<std::remove_cvref_t<H1>> or std::is_class_v<std::remove_cvref_t<H2>>)) | |
| ODhashTable (size_t len, H1 &&first_hash_fct, H2 &&second_hash_fct, Cmp cmp, float lower_alpha, float upper_alpha, bool with_resize) | |
| Builds a table when a hash function is a lambda without captures. | |
| ~ODhashTable () | |
| Free the whole hash table. | |
| ODhashTable (const ODhashTable &other) | |
| Copy constructor. | |
| ODhashTable (ODhashTable &&other) noexcept | |
| Move constructor. | |
| template<template< typename > class List> | |
| ODhashTable (const List< Key > &l) | |
| template<class It > requires (not std::is_arithmetic_v<It> and requires (It it) { *it; ++it; it != it; }) | |
| ODhashTable (It b, It e) | |
| ODhashTable (std::initializer_list< Key > l) | |
| ODhashTable & | operator= (const ODhashTable &other) |
| Copy assignment. | |
| ODhashTable & | operator= (ODhashTable &&other) noexcept |
| Hash_Fct | get_hash_fct () const noexcept |
| void | set_hash_fct (Hash_Fct fct) |
| void | set_hash_fct (Hash_Fct_Ptr fct) |
| Key * | search (const Key &key) noexcept |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. The same record, modifiable. | |
| const Key * | search (const Key &key) const noexcept |
| searches the table for the key. | |
| constexpr Hash_Fct | get_second_hash_fct () const noexcept |
| void | set_second_hash_fct (Hash_Fct fct) |
| Sets the hash function of the second probe. | |
| void | set_second_hash_fct (Hash_Fct_Ptr fct) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| void | remove (const Key &key) |
| Remove a key from the hash table. | |
| Stats | stats () const |
| constexpr bool | contains (const Key &key) const noexcept |
| Alias for has(). | |
Public Member Functions inherited from OhashCommon< HashTbl, Key > | |
| constexpr float | get_lower_alpha () const noexcept |
| Returns the lower load factor threshold for automatic shrinking. | |
| constexpr float | get_upper_alpha () const noexcept |
| Returns the upper load factor threshold for automatic growing. | |
| constexpr bool | get_with_resize () const noexcept |
| Returns whether the table resizes itself. | |
| void | set_with_resize (const bool with_resize) noexcept |
| Turns the automatic resizing on or off. | |
| void | copy_from_table (const HashTbl &other) |
| Copies all entries from another hash table. | |
| void | clean_table () |
| Removes all entries from the table without deallocating storage. | |
| bool | check_resize_before_insert () |
| Makes room for one more key, if the table can take it. | |
| Key * | insert (const Key &key) |
| Inserts a key into the hash table (copy version). | |
| Key * | insert (Key &&key) |
| Inserts a key into the hash table (move version). | |
| Key * | search_or_insert (const Key &key) |
| Searches for a key, inserting it if not found (copy version). | |
| Key * | search_or_insert (Key &&key) |
| Searches for a key, inserting it if not found (move version). | |
| std::pair< Key *, bool > | contains_or_insert (const Key &key) |
| Searches for a key, inserting if not found, with existence flag (copy version). | |
| std::pair< Key *, bool > | contains_or_insert (Key &&key) |
| Searches for a key, inserting if not found, with existence flag (move version). | |
| Key * | append (const Key &key) |
| Alias for insert() (copy version). | |
| Key * | append (Key &&key) |
| Alias for insert() (move version). | |
| constexpr bool | has (const Key &key) const noexcept |
| Checks if a key exists in the table. | |
| constexpr bool | contains (const Key &key) const noexcept |
| Alias for has(). | |
| Key & | find (const Key &key) |
| Finds a key and returns a reference to it. | |
| const Key & | find (const Key &key) const |
| Finds a key and returns a const reference to it. | |
| const Key & | operator[] (const Key &key) const |
| Subscript operator for const access. | |
| const Key & | operator[] (const Key &key) |
| Subscript operator with insertion semantics. | |
| void | remove_ptr (Key *key) |
| Removes an entry by pointer. | |
| size_t | resize (size_t new_size) |
| Resizes the hash table to a new capacity. | |
| void | rehash () |
| Rebuilds the hash table with the same capacity. | |
| void | empty () |
| Clears all entries and resets to default capacity. | |
| void | clear () |
| Empties the container. | |
| constexpr size_t | size () const noexcept |
| Returns the number of entries in the table. | |
| constexpr bool | is_empty () const noexcept |
| Checks if the table is empty. | |
| constexpr size_t | capacity () const noexcept |
| Returns the current capacity of the table. | |
| DynList< Key > | keys () const |
| Returns a list containing all keys in the table. | |
| auto | items () const |
| Alias for keys(). | |
| void | print_stats (const Stats &stats) const |
| Prints statistics to standard output. | |
| constexpr float | current_alpha () const noexcept |
| Returns the current load factor (alpha). | |
Public Member Functions inherited from GenericTraverse< Container > | |
| template<class Operation > requires Aleph::PredicateWith<Operation &, typename Aleph::concepts_detail::traverse_arg<Container, Operation>::type> | |
| bool | traverse (Operation &operation) noexcept(traverse_is_noexcept< Operation, typename Aleph::concepts_detail::traverse_arg< Container, Operation >::type, Container & >()) |
| Traverse the container via its iterator and performs a conditioned operation on each item. | |
| template<class Operation > requires Aleph::PredicateWith<Operation &, typename Aleph::concepts_detail::traverse_carg<Container, Operation>::type> | |
| bool | traverse (Operation &operation) const noexcept(traverse_is_noexcept< Operation, typename Aleph::concepts_detail::traverse_carg< Container, Operation >::type, const_source_t< Operation > >()) |
| Traverse a constant container; each item is handed out as a constant reference. | |
| template<class Operation > requires Aleph::PredicateWith<Operation &, typename Aleph::concepts_detail::traverse_carg<Container, Operation>::type> | |
| bool | traverse (Operation &&operation) const noexcept(traverse_is_noexcept< Operation, typename Aleph::concepts_detail::traverse_carg< Container, Operation >::type, const_source_t< Operation > >()) |
Overload of traverse(Operation &) const that accepts rvalues. | |
| template<class Operation > requires Aleph::PredicateWith<Operation &, typename Aleph::concepts_detail::traverse_arg<Container, Operation>::type> | |
| bool | traverse (Operation &&operation) noexcept(traverse_is_noexcept< Operation, typename Aleph::concepts_detail::traverse_arg< Container, Operation >::type, Container & >()) |
Overload of traverse(Operation &) that accepts rvalues. | |
Public Member Functions inherited from LocateFunctions< Container, Type > | |
| auto | get_it () |
| Return a properly initialized iterator positioned at the first item on the container. | |
| auto | get_it () const |
| Read-only iterator positioned at the first item. | |
| auto | get_it (const size_t pos) |
Return a properly initialized iterator positioned at the pos item on the container. | |
| auto | get_it (const size_t pos) const |
Read-only iterator positioned at the pos item. | |
| auto | get_itor () |
Alias of get_it(). | |
| auto | get_itor () const |
See get_itor(). | |
| template<class C = Container> requires Aleph::dry_detail::MutablyTraversable<C, Type> | |
| Type & | nth_ne (const size_t n) noexcept(Aleph::dry_detail::mutable_traversal_is_noexcept< C, Type >) |
| Return the n‑th element without bounds checking. | |
| const Type & | nth_ne (const size_t n) const noexcept(Aleph::dry_detail::const_traversal_is_noexcept< Container, Type >) |
Constant overload of nth_ne(size_t). | |
| template<class C = Container> requires Aleph::dry_detail::MutablyTraversable<C, Type> | |
| Type & | nth (const size_t n) |
| Return the n-th item of the container. | |
| const Type & | nth (const size_t n) const |
Const overload of nth(size_t). | |
| template<class Operation > requires Aleph::InvocablePredicateWith<Operation &, Type &> | |
| and Aleph::dry_detail::MutablyTraversable< typename Aleph::concepts_detail::defer< Container, Operation >::type, Type > Type * | find_ptr (Operation &operation) noexcept(mutable_search_is_noexcept< Operation >()) |
| Find a pointer to an item in the container according to a searching criterion. | |
| template<class Operation > requires Aleph::InvocablePredicateWith<Operation &, const Type &> | |
| const Type * | find_ptr (Operation &operation) const noexcept(const_search_is_noexcept< Operation >()) |
Const overload of find_ptr(Operation&). | |
| template<class Operation > requires Aleph::InvocablePredicateWith<Operation &, const Type &> | |
| const Type * | find_ptr (Operation &&operation) const noexcept(const_search_is_noexcept< Operation >()) |
| Overload of find_ptr() const that accepts rvalues. | |
| template<class Operation > requires Aleph::InvocablePredicateWith<Operation &, Type &> | |
| and Aleph::dry_detail::MutablyTraversable< typename Aleph::concepts_detail::defer< Container, Operation >::type, Type > Type * | find_ptr (Operation &&operation) noexcept(mutable_search_is_noexcept< Operation >()) |
| Overload of find_ptr() that accepts rvalues. | |
| template<class Operation > requires Aleph::InvocablePredicateWith<Operation &, const Type &> | |
| size_t | find_index (Operation &operation) const noexcept(const_search_is_noexcept< Operation >()) |
| Find the position of an item in the container according to a searching criterion. | |
| template<class Operation > requires Aleph::InvocablePredicateWith<Operation &, const Type &> | |
| size_t | find_index (Operation &&operation) const noexcept(const_search_is_noexcept< Operation >()) |
| Overload of find_index() that accepts rvalues. | |
| template<class Operation , class T = Type> requires Aleph::InvocablePredicateWith<Operation &, const Type &> | |
| and std::default_initializable< T > and std::copy_constructible< T > std::tuple< bool, Type > | find_item (Operation &operation) const noexcept(find_item_is_noexcept< Operation >()) |
| Safe sequential searching of an item matching a criterion. | |
| template<class Operation , class T = Type> requires Aleph::InvocablePredicateWith<Operation &, const Type &> | |
| and std::default_initializable< T > and std::copy_constructible< T > std::tuple< bool, Type > | find_item (Operation &&operation) const noexcept(find_item_is_noexcept< Operation >()) |
| Overload of find_item() that accepts rvalues. | |
| template<class Operation , class T = Type> requires Aleph::InvocablePredicateWith<Operation &, const Type &> | |
| and std::copy_constructible< T > std::optional< Type > | find_opt (Operation &operation) const |
| Copy of the first item satisfying a criterion, if any. | |
| template<class Operation , class T = Type> requires Aleph::InvocablePredicateWith<Operation &, const Type &> | |
| and std::copy_constructible< T > std::optional< Type > | find_opt (Operation &&operation) const |
| Overload of find_opt() that accepts rvalues. | |
| template<class Operation > requires Aleph::InvocablePredicateWith<Operation &, const Type &> | |
| bool | contains_if (Operation &&operation) const noexcept(const_search_is_noexcept< Operation >()) |
| Test if an item satisfying a criterion is present in the container. | |
| template<class T = Type> requires requires(const T & a, const T & b) { { a == b } -> std::convertible_to<bool>; } | |
| bool | contains (const Type &item) const |
| Test if an item is present in the container using equality. | |
Public Member Functions inherited from FunctionalMethods< Container, T > | |
| void | emplace (Args &&... args) |
| Appends a new element into the container by constructing it from the given args. | |
| void | emplace_end (Args &&... args) |
See emplace(Args && ... args). | |
| void | emplace_ins (Args &&... args) |
| template<typename... Args> requires ((std::convertible_to<Args &&, T> and ...) and (Aleph::InsertableWith<typename Aleph::concepts_detail::defer<Container, std::tuple<Args...>>::type, Item_Arg<Args>> and ...)) | |
| size_t | ninsert (Args &&... args) |
| Insert n variadic items. | |
| template<typename... Args> requires ((std::convertible_to<Args &&, T> and ...) and (Aleph::AppendableWith<typename Aleph::concepts_detail::defer<Container, std::tuple<Args...>>::type, Item_Arg<Args>> and ...)) | |
| size_t | nappend (Args &&... args) |
| Append n variadic items. | |
| template<class Operation > requires Aleph::InvocableWith<Operation &, const T &> | |
| void | for_each (Operation &operation) const |
| Traverse all the container and performs an operation on each element. | |
| template<class Operation > requires Aleph::InvocableWith<Operation &, const T &> | |
| void | for_each (Operation &&operation) const |
| Overload of for_each() that accepts rvalues. | |
| template<class Operation > requires Aleph::InvocableWith<Operation &, const T &> | |
| void | each (Operation &operation) const |
| Alias of for_each(). | |
| template<class Operation > requires Aleph::InvocableWith<Operation &, const T &> | |
| void | each (Operation &&operation) const |
| Alias of for_each() that accepts rvalues. | |
| template<class Operation > requires Aleph::InvocableWith<Operation &, const T &> | |
| void | each (const size_t pos, const size_t slice, Operation &operation) const |
Traverse the container starting at pos taking one item every slice, performing an operation on each visited element. | |
| template<class Operation > requires Aleph::InvocableWith<Operation &, const T &> | |
| void | each (const size_t pos, const size_t slice, Operation &&operation) const |
See each(size_t pos, size_t slice, Operation & operation) const. | |
| template<class Operation > requires Aleph::InvocableWith<Operation &, T &> | |
| and Aleph::dry_detail::MutablyTraversable< typename Aleph::concepts_detail::defer< Container, Operation >::type, T > void | each (const size_t pos, const size_t slice, Operation &operation) |
Traverse the container starting at pos taking one item every slice, performing an operation that may modify each visited item. | |
| template<class Operation > requires Aleph::InvocableWith<Operation &, T &> | |
| and Aleph::dry_detail::MutablyTraversable< typename Aleph::concepts_detail::defer< Container, Operation >::type, T > void | each (const size_t pos, const size_t slice, Operation &&operation) |
See each(size_t pos, size_t slice, Operation & operation). | |
| template<class Operation > requires Aleph::InvocableWith<Operation &, T &> | |
| and Aleph::dry_detail::MutablyTraversable< typename Aleph::concepts_detail::defer< Container, Operation >::type, T > void | mutable_for_each (Operation &operation) |
| Apply a mutable operation to each element of the container. | |
| template<class Operation > requires Aleph::InvocableWith<Operation &, T &> | |
| and Aleph::dry_detail::MutablyTraversable< typename Aleph::concepts_detail::defer< Container, Operation >::type, T > void | mutable_for_each (Operation &&operation) |
See mutable_for_each(Operation & operation). | |
| template<class Operation > requires Aleph::InvocablePredicateWith<Operation &, const T &> | |
| bool | all (Operation &operation) const |
| Check if all the elements of the container satisfy a condition. | |
| template<class Operation > requires Aleph::InvocablePredicateWith<Operation &, const T &> | |
| bool | all (Operation &&operation) const |
| Overload of all() that accepts rvalues. | |
| template<class Operation > requires Aleph::InvocablePredicateWith<Operation &, const T &> | |
| bool | exists (Operation &op) const |
| Test for existence in the container of an element satisfying a criterion. | |
| template<class Operation > requires Aleph::InvocablePredicateWith<Operation &, const T &> | |
| bool | exists (Operation &&op) const |
| Overload of exists() that accepts rvalues. | |
| template<class Operation > requires Aleph::InvocablePredicateWith<Operation &, const T &> | |
| bool | none (Operation &op) const |
| Test that no element satisfies a criterion. | |
| template<class Operation > requires Aleph::InvocablePredicateWith<Operation &, const T &> | |
| bool | none (Operation &&op) const |
| Overload of none() that accepts rvalues. | |
| template<class Operation > requires Aleph::InvocablePredicateWith<Operation &, const T &> | |
| size_t | count_if (Operation &op) const |
| Count the elements that satisfy a criterion. | |
| template<class Operation > requires Aleph::InvocablePredicateWith<Operation &, const T &> | |
| size_t | count_if (Operation &&op) const |
| Overload of count_if() that accepts rvalues. | |
| Aleph::DynList< Aleph::dry_detail::map_result_t< R, Operation &, T > > | maps (Operation &op) const |
| Aleph::DynList< Aleph::dry_detail::map_result_t< R, Operation &, T > > | maps (Operation &&op) const |
| Aleph::DynList< Aleph::dry_detail::map_result_t< R, Operation &, T > > | maps_if (Prop prop, Operation &op) const |
| Aleph::DynList< Aleph::dry_detail::map_result_t< R, Operation &, T > > | maps_if (Prop prop, Operation &&op) const |
| Aleph::DynList< Aleph::dry_detail::map_result_t< R, Operation &, T > > | map (Operation &op) const |
| Aleph::DynList< Aleph::dry_detail::map_result_t< R, Operation &, T > > | map (Operation &&op) const |
| Aleph::DynList< Aleph::dry_detail::map_result_t< R, Operation &, T > > | map_if (Prop prop, Operation &op) const |
| Aleph::DynList< Aleph::dry_detail::map_result_t< R, Operation &, T > > | map_if (Prop prop, Operation &&op) const |
| template<class Operation > requires Aleph::InvocableWith<Operation &, const T &> | |
| auto | flat_map (Operation &op) const |
| Map each element to a container and concatenate the results. | |
| template<class Operation > requires Aleph::InvocableWith<Operation &, const T &> | |
| auto | flat_map (Operation &&op) const |
| Overload of flat_map() that accepts rvalues. | |
| Aleph::DynList< T > | to_dynlist () const |
| Convert container to DynList. | |
| std::vector< T > | to_vector () const |
| Convert container to std::vector. | |
| template<typename Acc = T, class Op > requires Aleph::dry_detail::FoldOperation<Op, Acc, T> | |
| Acc | foldl (const Acc &init, Op &op) const |
| Fold the elements of the container to a specific result. | |
| template<typename Acc = T, class Op > requires Aleph::dry_detail::FoldOperation<Op, Acc, T> | |
| Acc | foldl (const Acc &init, Op &&op) const |
| Overload of foldl() that accepts rvalues. | |
| template<typename Acc = T, class Op > requires Aleph::dry_detail::FoldOperation<Op, Acc, T> | |
| Acc | fold_left (const Acc &init, Op &op) const |
| Alias for foldl(). | |
| template<typename Acc = T, class Op > requires Aleph::dry_detail::FoldOperation<Op, Acc, T> | |
| Acc | fold_left (const Acc &init, Op &&op) const |
| Overload of fold_left() that accepts rvalues. | |
| template<class Operation > requires Aleph::dry_detail::FoldOperation<Operation, T, T> | |
| T | fold (const T &init, Operation &operation) const |
| Simplified version of foldl() where the folded type is the same type of elements stored in the container. | |
| template<class Operation > requires Aleph::dry_detail::FoldOperation<Operation, T, T> | |
| T | fold (const T &init, Operation &&operation) const |
| Overload of fold() that accepts rvalues. | |
| template<typename Acc = T, class Op > requires Aleph::dry_detail::FoldRightOperation<Op, Acc, T> | |
| Acc | foldr (const Acc &init, Op &op) const |
| Fold the elements from the last to the first. | |
| template<typename Acc = T, class Op > requires Aleph::dry_detail::FoldRightOperation<Op, Acc, T> | |
| Acc | foldr (const Acc &init, Op &&op) const |
| Overload of foldr() that accepts rvalues. | |
| template<class Op , class U = T> requires Aleph::dry_detail::FoldOperation<Op, T, T> | |
| and std::copy_constructible< U > std::optional< T > | reduce (Op &op) const |
| Fold the elements with no initial value. | |
| template<class Op , class U = T> requires Aleph::dry_detail::FoldOperation<Op, T, T> | |
| and std::copy_constructible< U > std::optional< T > | reduce (Op &&op) const |
| Overload of reduce() that accepts rvalues. | |
| template<class Operation > requires Aleph::InvocablePredicateWith<Operation &, const T &> | |
| Aleph::DynList< T > | filter (Operation &operation) const |
| Filter the elements of a container according to a matching criterion. | |
| template<class Operation > requires Aleph::InvocablePredicateWith<Operation &, const T &> | |
| Aleph::DynList< T > | filter (Operation &&operation) const |
| Overload of filter() that accepts rvalues. | |
| template<class Operation > requires Aleph::InvocablePredicateWith<Operation &, const T &> | |
| Aleph::DynList< const T * > | ptr_filter (Operation &operation) const |
| Filter the elements of a container according to a matching criterion and return a pointer to the matched items in the container. | |
| template<class Operation > requires Aleph::InvocablePredicateWith<Operation &, const T &> | |
| Aleph::DynList< const T * > | ptr_filter (Operation &&operation) const |
| Overload of ptr_filter() that accepts rvalues. | |
| template<class Operation > requires Aleph::InvocablePredicateWith<Operation &, const T &> | |
| Aleph::DynList< std::tuple< T, size_t > > | pfilter (Operation &operation) const |
| Filter the elements of a container according to a matching criterion and determine its positions respect to the traversal of container. | |
| template<class Operation > requires Aleph::InvocablePredicateWith<Operation &, const T &> | |
| Aleph::DynList< std::tuple< T, size_t > > | pfilter (Operation &&operation) const |
| Overload of pfilter() that accepts rvalues. | |
| template<class Operation > requires Aleph::InvocablePredicateWith<Operation &, const T &> | |
| std::pair< Aleph::DynList< T >, Aleph::DynList< T > > | partition (Operation &op) const |
| Exclusive partition of container according to a filter criterion. | |
| template<class Operation > requires Aleph::InvocablePredicateWith<Operation &, const T &> | |
| std::pair< Aleph::DynList< T >, Aleph::DynList< T > > | partition (Operation &&op) const |
| Overload of partition() that accepts rvalues. | |
| std::pair< Aleph::DynList< T >, Aleph::DynList< T > > | partition (size_t n) const |
| Exclusive partition of container in the nth item. | |
| std::pair< Aleph::DynList< T >, Aleph::DynList< T > > | split_half () const |
| Split the container into two halves by alternating elements. | |
| template<class Operation > requires Aleph::InvocablePredicateWith<Operation &, const T &> | |
| std::tuple< Aleph::DynList< T >, Aleph::DynList< T > > | tpartition (Operation &op) const |
| Exclusive partition of container according to a filter criterion. | |
| template<class Operation > requires Aleph::InvocablePredicateWith<Operation &, const T &> | |
| std::tuple< Aleph::DynList< T >, Aleph::DynList< T > > | tpartition (Operation &&op) const |
| Overload of tpartition() that accepts rvalues. | |
| size_t | length () const noexcept(Aleph::dry_detail::const_traversal_is_noexcept< Container, T >) |
| Count the number of elements of a container. | |
| Aleph::DynList< T > | rev () const |
| Return a list with the elements of container in reverse order respect to its traversal order. | |
| Aleph::DynList< T > | take (const size_t n) const |
| Return a list with the first n elements seen in the container during its traversal. | |
| Aleph::DynList< T > | take (size_t i, const size_t j, const size_t step=1) const |
Return a list with the elements at positions i, i + step, i + 2 step, ... that are not greater than j, respect to the traversal order. | |
| Aleph::DynList< T > | drop (const size_t n) const |
| Drop the first n elements seen in the container during its traversal. | |
| template<class Operation > requires Aleph::InvocablePredicateWith<Operation &, const T &> | |
| Aleph::DynList< T > | take_while (Operation &op) const |
| The longest prefix of elements that satisfy a criterion. | |
| template<class Operation > requires Aleph::InvocablePredicateWith<Operation &, const T &> | |
| Aleph::DynList< T > | take_while (Operation &&op) const |
| Overload of take_while() that accepts rvalues. | |
| template<class Operation > requires Aleph::InvocablePredicateWith<Operation &, const T &> | |
| Aleph::DynList< T > | drop_while (Operation &op) const |
| The elements after the longest prefix that satisfies a criterion. | |
| template<class Operation > requires Aleph::InvocablePredicateWith<Operation &, const T &> | |
| Aleph::DynList< T > | drop_while (Operation &&op) const |
| Overload of drop_while() that accepts rvalues. | |
| template<class C = Container> requires requires (C & c) { c.remove(); } | |
| void | mutable_drop (const size_t n) |
| Drop the first n elements seen from container. | |
Public Member Functions inherited from EqualToMethod< Container > | |
| template<class C = Container> requires Aleph::dry_detail::SetSearchable<C> | |
| bool | equal_to (const Container &r) const |
Test if elements of this are exactly contained in another container. | |
Public Member Functions inherited from StlAlephIterator< SetName > | |
| iterator | begin () noexcept |
| Return an STL-compatible iterator to the first element. | |
| iterator | end () noexcept |
| Return an STL-compatible end iterator. | |
| const_iterator | begin () const noexcept |
| Return a const iterator to the first element. | |
| const_iterator | end () const noexcept |
| Return a const end iterator. | |
| const_iterator | cbegin () const noexcept |
| Return a const iterator to the first element. | |
| const_iterator | cend () const noexcept |
| Return a const end iterator. | |
Static Public Member Functions | |
| static Bucket * | key_to_bucket (Key *rec) noexcept |
Static Public Member Functions inherited from FunctionalMethods< Container, T > | |
| template<typename... Items> requires ((std::convertible_to<Items &&, T> and ...) and (Aleph::AppendableWith<typename Aleph::concepts_detail::defer<Container, std::tuple<Items...>>::type, Item_Arg<Items>> and ...)) | |
| static Container | build (Items &&... items) |
| Build a container that holds the given items. | |
| template<class D , typename... Items> requires (std::derived_from<D, typename Aleph::concepts_detail::defer<Container, D>::type> and std::default_initializable<D> and (std::convertible_to<Items &&, T> and ...) and (Aleph::AppendableWith<typename Aleph::concepts_detail::defer<Container, std::tuple<D, Items...>>::type, Item_Arg<Items>> and ...)) | |
| static D | build_as (Items &&... items) |
Build a D, a class derived from the container, holding the given items. | |
Public Attributes | |
| Bucket * | table = nullptr |
| Hash_Fct | hash_fct = nullptr |
| Hash_Fct | second_hash_fct = nullptr |
| Cmp | cmp |
Public Attributes inherited from FunctionalMethods< Container, T > | |
| template<typename... Args> requires (typename Aleph::concepts_detail::defer<Container, std::tuple<Args...>>::type & c, T && x) | |
| and { c.append(std::move(x)) | |
| Insert a new element into the container by constructing it from the given args. | |
| template<typename R = void, class Prop , class Operation > requires (Aleph::DynList<Aleph::dry_detail::map_result_t<R, Operation &, T>> & l, Operation & op, const T & item) | |
| and Aleph::InvocableWith< Operation &, const T & > | and { l.append(std::invoke(op, item)) |
| Conditional mapping of the elements of the container. | |
Protected Member Functions | |
| ODhashTable (const size_t l, Hash_Fct fst_hash_fct, Hash_Fct snd_hash_fct, Cmp cpm_fct, const float lower, const float upper, const bool resize) | |
Protected Member Functions inherited from OhashCommon< HashTbl, Key > | |
| void | rebuild (const size_t new_len) |
Places the keys of the table in new_len new buckets. | |
| size_t | rebuild_capacity () const |
| Capacity to rebuild a table that resizes itself with, when its buckets in use are too many. | |
| size_t | capacity_after_insertion () const |
| Capacity that an insertion leaves the table with, or 0 if it keeps it. | |
| void | shrink_after_removal () noexcept |
| Shrinks a table that resizes itself, after a removal took its load factor under the lower threshold. | |
Protected Attributes | |
| size_t | len |
| float | lower_alpha |
| float | upper_alpha |
Private Member Functions | |
| Bucket * | allocate_bucket (Bucket &bucket, unsigned char probe_type) noexcept |
| void | decrease_probe_counter (Bucket *bucket) noexcept |
| void | deallocate_bucket (Bucket *bucket) noexcept |
| void | undo_allocate_bucket (Bucket *bucket, const Key &key) noexcept |
Undoes what allocate_bucket() or hard_allocate_bucket() did when they reserved bucket for key, which was never stored in it. | |
| size_t | index_forward (size_t &i) const noexcept |
| size_t | index_backward (size_t &i) const noexcept |
| bool | is_valid_bucket (Bucket *bucket) const noexcept |
| size_t | bucket_to_index (Bucket *bucket) const noexcept |
| bool | is_key_in_table (const Key &key) const noexcept |
| Returns true if the key reference points to a key inside the table. | |
| Bucket * | key_in_table_to_bucket (const Key &key) noexcept |
| Converts a key reference inside the table to its containing bucket. | |
| template<typename RecordBucket > | |
| void | deallocate_bucket_with_record (Bucket *bucket, RecordBucket &&record_bucket) noexcept |
| Template version of deallocate_bucket that accepts a callback to record modified buckets before decrementing their probe_counter. | |
| template<typename RecordBucket > | |
| void | release_bucket (Bucket *bucket, const Key &key, RecordBucket &&record_bucket) noexcept |
Frees bucket, which was reached with the probe sequence of key, and walks that sequence back: every bucket that the insertion of key counted is counted down. | |
| Key * | test_resize (Bucket *curr_bucket, const Key &key) |
| Key * | rebuild_after_insertion (Bucket *curr_bucket, const Key &key, const size_t new_len) |
| Bucket * | allocate_bucket (const Key &key) noexcept |
| std::tuple< Bucket *, bool > | hard_allocate_bucket (const Key &key) noexcept |
| void | remove_bucket (Bucket *bucket) |
| Delete the record from the table. | |
| void | remove_without_shrinking (const Key &key) |
Static Private Member Functions | |
| static void | update_stat_len (DynArray< size_t > &lens, size_t i) |
Private Attributes | |
| size_t | N |
| bool | with_resize |
| size_t | deleted_buckets = 0 |
Friends | |
| class | OhashCommon< ODhashTable< Key, Cmp >, Key > |
Open addressing hash table with double hashing collision resolution.
This class implements a closed hash table (contiguous memory array) that resolves collisions using double hashing. When a collision occurs, a second hash function is called to probe for an available bucket. If the second probe also collides, linear probing continues from that index.
The table uses a probe counter mechanism that enables O(1) deletion without relocation. Each bucket tracks how many keys depend on it being in the collision chain, allowing efficient garbage collection of DELETED entries.
Based on the algorithms described in Knuth's "The Art of Computer Programming", Volume 3.
| Key | The type of keys stored in the table. |
| Cmp | Comparison functor for keys (default: Aleph::equal_to<Key>). Must return true if two keys are equal. |
set_hash_fct() and set_second_hash_fct() place the stored keys again with the new function, as rehash() does: on a table that is not empty each takes O(n).Definition at line 186 of file tpl_odhash.H.
| using Aleph::ODhashTable< Key, Cmp >::Base = OhashCommon<ODhashTable<Key, Cmp>, Key> |
Instantiate a closed hash table with collision resolution by double hashing.
| [in] | first_hash_fct | hash function for the first probe. |
| [in] | second_hash_fct | hash function for the second probe. |
| cmp | comparison functor for keys. Must return true if two keys are equal. By default, Aleph::equal_to<Key> is used. | |
| lower_alpha | lower load factor threshold for resizing. When the load factor goes below this value, the table shrinks. 0 < lower_alpha < upper_alpha < 1. 0.25 is a reasonable default. 0.1 gives faster operations but uses more memory. | |
| upper_alpha | upper load factor threshold for resizing. When the load factor goes above this value, the table expands. 0 < lower_alpha < upper_alpha < 1. 0.5 is a reasonable default. 0.7 gives faster operations but uses more memory. | |
| with_resize | if true, the table resizes automatically when load factor thresholds are crossed. | |
| [in] | len | table size. |
| overflow_error | if the bytes of len buckets do not fit in a size_t. |
| bad_alloc | if there is no memory for the bucket table. |
Definition at line 524 of file tpl_odhash.H.
| using Aleph::ODhashTable< Key, Cmp >::Hash_Fct = std::function<size_t(const Key &)> |
Definition at line 201 of file tpl_odhash.H.
| using Aleph::ODhashTable< Key, Cmp >::Hash_Fct_Ptr = size_t (*)(const Key &) |
Definition at line 203 of file tpl_odhash.H.
| using Aleph::ODhashTable< Key, Cmp >::Item_Type = Key |
Definition at line 199 of file tpl_odhash.H.
| using Aleph::ODhashTable< Key, Cmp >::Key_Type = Key |
Definition at line 197 of file tpl_odhash.H.
| using Aleph::ODhashTable< Key, Cmp >::Stats = typename OhashCommon<ODhashTable<Key, Cmp>, Key>::Stats |
Definition at line 1143 of file tpl_odhash.H.
| enum Aleph::ODhashTable::Probe |
| Enumerator | |
|---|---|
| NO_PROBED | |
| FIRST_PROBE | |
| SECOND_PROBE | |
| LINEAR_PROBE | |
Definition at line 207 of file tpl_odhash.H.
| enum Aleph::ODhashTable::Status |
| Enumerator | |
|---|---|
| EMPTY | |
| BUSY | |
| DELETED | |
Definition at line 205 of file tpl_odhash.H.
|
inlineprotected |
Definition at line 485 of file tpl_odhash.H.
References Aleph::ODhashTable< Key, Cmp >::len, and Aleph::ODhashTable< Key, Cmp >::table.
|
inline |
Definition at line 528 of file tpl_odhash.H.
|
inline |
Builds a table when a hash function is a lambda without captures.
A lambda without captures converts both to Hash_Fct and to Hash_Fct_Ptr, so with every parameter given the call was ambiguous. This constructor takes the two functions as they are; each of them may be a lambda without captures or a function pointer.
| [in] | len | Requested capacity; the next prime is used. |
| [in] | first_hash_fct | Hash function for the first probe. |
| [in] | second_hash_fct | Hash function for the second probe. |
| [in] | cmp | Equality comparator for keys. |
| [in] | lower_alpha | Load factor under which the table shrinks. |
| [in] | upper_alpha | Load factor over which the table grows. |
| [in] | with_resize | Whether the table resizes itself. |
| std::bad_alloc | If there is no memory for the buckets. |
Definition at line 560 of file tpl_odhash.H.
|
inline |
Free the whole hash table.
Definition at line 569 of file tpl_odhash.H.
References Aleph::ODhashTable< Key, Cmp >::table.
|
inline |
Copy constructor.
The copy has the keys, both hash functions, the comparator, the load thresholds and the resizing policy of other, and its capacity. A table whose storage was taken by a move is copied as a table of the default capacity.
| [in] | other | Table to copy. |
| std::bad_alloc | If there is no memory for the buckets. |
Definition at line 585 of file tpl_odhash.H.
References OhashCommon< HashTbl, Key >::copy_from_table(), and Aleph::ODhashTable< Key, Cmp >::table.
|
inlinenoexcept |
Move constructor.
Takes the buckets of other in constant time and without allocating them. The new table also gets a copy of both hash functions, the comparator, the load thresholds and the resizing policy, which other keeps.
| [in,out] | other | Table to take the keys from. It is left empty, with capacity zero. It is still usable: the first insertion gives it a table of the default capacity. |
std::terminate is called. A function pointer and a comparator without state never throw. Definition at line 609 of file tpl_odhash.H.
|
inline |
Definition at line 623 of file tpl_odhash.H.
|
inline |
Definition at line 623 of file tpl_odhash.H.
|
inline |
Definition at line 623 of file tpl_odhash.H.
|
inlineprivatenoexcept |
Definition at line 282 of file tpl_odhash.H.
References Aleph::ODhashTable< Key, Cmp >::BUSY, Aleph::ODhashTable< Key, Cmp >::DELETED, Aleph::ODhashTable< Key, Cmp >::deleted_buckets, and Aleph::ODhashTable< Key, Cmp >::N.
Referenced by Aleph::ODhashTable< Key, Cmp >::allocate_bucket(), and Aleph::ODhashTable< Key, Cmp >::hard_allocate_bucket().
|
inlineprivatenoexcept |
Definition at line 775 of file tpl_odhash.H.
References Aleph::ODhashTable< Key, Cmp >::allocate_bucket(), Aleph::ODhashTable< Key, Cmp >::BUSY, Aleph::ODhashTable< Key, Cmp >::cmp, Aleph::ODhashTable< Key, Cmp >::DELETED, Aleph::ODhashTable< Key, Cmp >::EMPTY, Aleph::ODhashTable< Key, Cmp >::FIRST_PROBE, Aleph::ODhashTable< Key, Cmp >::hash_fct, Aleph::ODhashTable< Key, Cmp >::index_forward(), k, Aleph::ODhashTable< Key, Cmp >::len, Aleph::ODhashTable< Key, Cmp >::LINEAR_PROBE, Aleph::ODhashTable< Key, Cmp >::Bucket::probe_counter, Aleph::ODhashTable< Key, Cmp >::second_hash_fct, Aleph::ODhashTable< Key, Cmp >::SECOND_PROBE, and Aleph::ODhashTable< Key, Cmp >::table.
|
inlineprivatenoexcept |
Definition at line 357 of file tpl_odhash.H.
References Aleph::ODhashTable< Key, Cmp >::is_valid_bucket(), and Aleph::ODhashTable< Key, Cmp >::table.
|
inlineconstexprnoexcept |
Alias for has().
| key | The key to search for. |
Definition at line 769 of file hashDry.H.
Referenced by TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), and Moved_From_Case< PersistentHashMap< int, int > >::use().
|
inlineprivatenoexcept |
Definition at line 310 of file tpl_odhash.H.
References Aleph::ODhashTable< Key, Cmp >::deallocate_bucket_with_record().
Referenced by Aleph::ODhashTable< Key, Cmp >::remove_bucket(), and Aleph::ODhashTable< Key, Cmp >::remove_without_shrinking().
|
inlineprivatenoexcept |
Template version of deallocate_bucket that accepts a callback to record modified buckets before decrementing their probe_counter.
Definition at line 390 of file tpl_odhash.H.
References Aleph::ODhashTable< Key, Cmp >::release_bucket().
Referenced by Aleph::ODhashTable< Key, Cmp >::deallocate_bucket().
|
inlineprivatenoexcept |
Definition at line 296 of file tpl_odhash.H.
References Aleph::ODhashTable< Key, Cmp >::BUSY, Aleph::ODhashTable< Key, Cmp >::DELETED, Aleph::ODhashTable< Key, Cmp >::deleted_buckets, and Aleph::ODhashTable< Key, Cmp >::EMPTY.
Referenced by Aleph::ODhashTable< Key, Cmp >::release_bucket().
|
inlineconstexprnoexcept |
Definition at line 455 of file tpl_odhash.H.
References Aleph::ODhashTable< Key, Cmp >::cmp.
|
inlineconstexprnoexcept |
Definition at line 457 of file tpl_odhash.H.
References Aleph::ODhashTable< Key, Cmp >::cmp.
|
inlinenoexcept |
Definition at line 653 of file tpl_odhash.H.
|
inlineconstexprnoexcept |
Definition at line 737 of file tpl_odhash.H.
References Aleph::ODhashTable< Key, Cmp >::second_hash_fct.
|
inlineprivatenoexcept |
Definition at line 901 of file tpl_odhash.H.
References AH_ERROR, Aleph::ODhashTable< Key, Cmp >::allocate_bucket(), Aleph::ODhashTable< Key, Cmp >::BUSY, Aleph::ODhashTable< Key, Cmp >::cmp, Aleph::ODhashTable< Key, Cmp >::DELETED, Aleph::ODhashTable< Key, Cmp >::EMPTY, Aleph::ODhashTable< Key, Cmp >::FIRST_PROBE, Aleph::ODhashTable< Key, Cmp >::hash_fct, Aleph::ODhashTable< Key, Cmp >::index_forward(), k, Aleph::ODhashTable< Key, Cmp >::len, Aleph::ODhashTable< Key, Cmp >::LINEAR_PROBE, Aleph::ODhashTable< Key, Cmp >::Bucket::probe_counter, Aleph::ODhashTable< Key, Cmp >::second_hash_fct, Aleph::ODhashTable< Key, Cmp >::SECOND_PROBE, and Aleph::ODhashTable< Key, Cmp >::table.
|
inlineprivatenoexcept |
Definition at line 332 of file tpl_odhash.H.
References Aleph::ODhashTable< Key, Cmp >::len.
|
inlineprivatenoexcept |
Definition at line 324 of file tpl_odhash.H.
References Aleph::ODhashTable< Key, Cmp >::len.
Referenced by Aleph::ODhashTable< Key, Cmp >::allocate_bucket(), Aleph::ODhashTable< Key, Cmp >::hard_allocate_bucket(), Aleph::ODhashTable< Key, Cmp >::release_bucket(), Aleph::ODhashTable< Key, Cmp >::remove_without_shrinking(), Aleph::ODhashTable< Key, Cmp >::search(), and Aleph::ODhashTable< Key, Cmp >::stats().
|
inlineprivatenoexcept |
Returns true if the key reference points to a key inside the table.
Definition at line 364 of file tpl_odhash.H.
References Aleph::ODhashTable< Key, Cmp >::len, and Aleph::ODhashTable< Key, Cmp >::table.
Referenced by Aleph::ODhashTable< Key, Cmp >::key_in_table_to_bucket(), and Aleph::ODhashTable< Key, Cmp >::remove_without_shrinking().
|
inlineprivatenoexcept |
Definition at line 340 of file tpl_odhash.H.
References StlAlephIterator< SetName >::begin(), StlAlephIterator< SetName >::end(), Aleph::ODhashTable< Key, Cmp >::len, and Aleph::ODhashTable< Key, Cmp >::table.
Referenced by Aleph::ODhashTable< Key, Cmp >::bucket_to_index(), and Aleph::ODhashTable< Key, Cmp >::remove_bucket().
|
inlineprivatenoexcept |
Converts a key reference inside the table to its containing bucket.
Definition at line 381 of file tpl_odhash.H.
References Aleph::ODhashTable< Key, Cmp >::is_key_in_table(), and Aleph::ODhashTable< Key, Cmp >::key_to_bucket().
Referenced by Aleph::ODhashTable< Key, Cmp >::remove_without_shrinking().
|
inlinestaticnoexcept |
Definition at line 448 of file tpl_odhash.H.
References offset.
Referenced by Aleph::ODhashTable< Key, Cmp >::key_in_table_to_bucket().
|
inline |
Copy assignment.
Leaves this table as a copy of other: the same keys, hash functions, comparator, load thresholds, resizing policy and capacity.
| [in] | other | Table to copy. |
| std::bad_alloc | If there is no memory for the copy. This table is left as it was. |
Definition at line 636 of file tpl_odhash.H.
References Aleph::ODhashTable< Key, Cmp >::swap().
|
inlinenoexcept |
Definition at line 647 of file tpl_odhash.H.
References Aleph::ODhashTable< Key, Cmp >::swap().
|
inlineprivate |
Definition at line 653 of file tpl_odhash.H.
|
inlineprivatenoexcept |
Frees bucket, which was reached with the probe sequence of key, and walks that sequence back: every bucket that the insertion of key counted is counted down.
key is the key stored in the bucket, or the key that the bucket was reserved for when storing it failed. record_bucket is called on each bucket before its counter goes down.
Definition at line 404 of file tpl_odhash.H.
References Aleph::ODhashTable< Key, Cmp >::BUSY, Aleph::ODhashTable< Key, Cmp >::decrease_probe_counter(), Aleph::ODhashTable< Key, Cmp >::DELETED, Aleph::ODhashTable< Key, Cmp >::deleted_buckets, Aleph::ODhashTable< Key, Cmp >::EMPTY, Aleph::ODhashTable< Key, Cmp >::FIRST_PROBE, Aleph::ODhashTable< Key, Cmp >::hash_fct, Aleph::ODhashTable< Key, Cmp >::index_forward(), Aleph::ODhashTable< Key, Cmp >::len, Aleph::ODhashTable< Key, Cmp >::LINEAR_PROBE, Aleph::ODhashTable< Key, Cmp >::N, Aleph::ODhashTable< Key, Cmp >::second_hash_fct, Aleph::ODhashTable< Key, Cmp >::SECOND_PROBE, and Aleph::ODhashTable< Key, Cmp >::table.
Referenced by Aleph::ODhashTable< Key, Cmp >::deallocate_bucket_with_record(), and Aleph::ODhashTable< Key, Cmp >::undo_allocate_bucket().
|
inline |
Remove a key from the hash table.
If key is a reference to a key inside the table (from search/insert), it uses the fast path via deallocate_bucket. If key is external, it searches for the key and removes it. Throws domain_error if the key is not found. A table that resizes itself may then shrink, as with remove_ptr(), so that its keys move.
Definition at line 1137 of file tpl_odhash.H.
References Aleph::ODhashTable< Key, Cmp >::remove_without_shrinking(), and OhashCommon< HashTbl, Key >::shrink_after_removal().
Referenced by demo_odhash(), main(), TEST(), TEST(), and TEST().
|
inlineprivate |
Delete the record from the table.
record must belong to the table and must have been previously determined by a insert or search. The invalid_argument exception is raised if the record does not correspond to a bucket in the table. It shoots domain_error if the record in the table does not contain an element.
Definition at line 1038 of file tpl_odhash.H.
References ah_domain_error_if, ah_invalid_argument_if, Aleph::ODhashTable< Key, Cmp >::BUSY, Aleph::ODhashTable< Key, Cmp >::deallocate_bucket(), Aleph::ODhashTable< Key, Cmp >::is_valid_bucket(), and Aleph::ODhashTable< Key, Cmp >::Bucket::status.
|
inlineprivate |
Definition at line 1048 of file tpl_odhash.H.
References ah_domain_error, ah_domain_error_if, FunctionalMethods< Container, T >::and, Aleph::ODhashTable< Key, Cmp >::BUSY, Aleph::ODhashTable< Key, Cmp >::cmp, Aleph::ODhashTable< Key, Cmp >::deallocate_bucket(), Aleph::ODhashTable< Key, Cmp >::DELETED, Aleph::ODhashTable< Key, Cmp >::EMPTY, Aleph::ODhashTable< Key, Cmp >::hash_fct, Aleph::ODhashTable< Key, Cmp >::index_forward(), Aleph::ODhashTable< Key, Cmp >::is_key_in_table(), Aleph::ODhashTable< Key, Cmp >::key_in_table_to_bucket(), Aleph::ODhashTable< Key, Cmp >::len, Aleph::ODhashTable< Key, Cmp >::second_hash_fct, Aleph::ODhashTable< Key, Cmp >::Bucket::status, and Aleph::ODhashTable< Key, Cmp >::table.
Referenced by Aleph::ODhashTable< Key, Cmp >::remove().
|
inlinenoexcept |
searches the table for the key.
Return a pointer to the record associated with key within the table; nullptr otherwise.
Definition at line 664 of file tpl_odhash.H.
References AH_ERROR, FunctionalMethods< Container, T >::and, Aleph::ODhashTable< Key, Cmp >::BUSY, Aleph::ODhashTable< Key, Cmp >::cmp, Aleph::count(), Aleph::ODhashTable< Key, Cmp >::DELETED, Aleph::ODhashTable< Key, Cmp >::EMPTY, Aleph::ODhashTable< Key, Cmp >::FIRST_PROBE, Aleph::ODhashTable< Key, Cmp >::hash_fct, Aleph::ODhashTable< Key, Cmp >::index_forward(), Aleph::ODhashTable< Key, Cmp >::Bucket::key, Aleph::ODhashTable< Key, Cmp >::len, Aleph::ODhashTable< Key, Cmp >::LINEAR_PROBE, Aleph::ODhashTable< Key, Cmp >::second_hash_fct, Aleph::ODhashTable< Key, Cmp >::SECOND_PROBE, and Aleph::ODhashTable< Key, Cmp >::table.
|
inlinenoexcept |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. The same record, modifiable.
Definition at line 657 of file tpl_odhash.H.
Referenced by demo_odhash(), demo_performance(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().
|
inline |
Definition at line 653 of file tpl_odhash.H.
Referenced by TEST_F().
|
inline |
Definition at line 653 of file tpl_odhash.H.
|
inline |
Sets the hash function of the second probe.
On a table that is not empty, it places the keys again with it, as rehash() does, so the keys already stored are still found.
| [in] | fct | The new hash function. |
| std::bad_alloc | if there is no memory for the new buckets, and what copying a key throws when its swap may throw; the table then keeps its function and its keys. |
Definition at line 750 of file tpl_odhash.H.
References OhashCommon< HashTbl, Key >::rehash(), and Aleph::ODhashTable< Key, Cmp >::second_hash_fct.
Referenced by Aleph::ODhashTable< Key, Cmp >::set_second_hash_fct(), and TEST().
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 769 of file tpl_odhash.H.
References Aleph::ODhashTable< Key, Cmp >::set_second_hash_fct().
|
inline |
Definition at line 1145 of file tpl_odhash.H.
References FunctionalMethods< Container, T >::and, Aleph::ODhashTable< Key, Cmp >::BUSY, Aleph::ODhashTable< Key, Cmp >::cmp, Aleph::count(), Aleph::ODhashTable< Key, Cmp >::DELETED, Aleph::ODhashTable< Key, Cmp >::deleted_buckets, Aleph::ODhashTable< Key, Cmp >::EMPTY, Aleph::ODhashTable< Key, Cmp >::FIRST_PROBE, Aleph::ODhashTable< Key, Cmp >::hash_fct, Aleph::ODhashTable< Key, Cmp >::index_forward(), Aleph::ODhashTable< Key, Cmp >::Bucket::key, Aleph::ODhashTable< Key, Cmp >::len, Aleph::ODhashTable< Key, Cmp >::second_hash_fct, Aleph::ODhashTable< Key, Cmp >::SECOND_PROBE, Aleph::DynArray< T >::size(), Aleph::ODhashTable< Key, Cmp >::stats(), Aleph::sum(), Aleph::ODhashTable< Key, Cmp >::table, and Aleph::ODhashTable< Key, Cmp >::update_stat_len().
Referenced by Aleph::ODhashTable< Key, Cmp >::stats().
|
inlinenoexcept |
Swaps this table with other in constant time.
The keys travel with everything that rules them: both hash functions, the comparator, the load thresholds and the resizing policy.
| [in,out] | other | Table to swap with. |
std::terminate is called. Definition at line 470 of file tpl_odhash.H.
References Aleph::ODhashTable< Key, Cmp >::cmp, Aleph::ODhashTable< Key, Cmp >::deleted_buckets, Aleph::ODhashTable< Key, Cmp >::hash_fct, Aleph::ODhashTable< Key, Cmp >::len, Aleph::ODhashTable< Key, Cmp >::lower_alpha, Aleph::ODhashTable< Key, Cmp >::second_hash_fct, hash_dry_detail::swap_compare(), Aleph::ODhashTable< Key, Cmp >::table, Aleph::ODhashTable< Key, Cmp >::upper_alpha, and Aleph::ODhashTable< Key, Cmp >::with_resize.
Referenced by Aleph::ODhashTable< Key, Cmp >::operator=(), Aleph::ODhashTable< Key, Cmp >::operator=(), TEST(), TEST(), TEST(), and TEST_F().
|
inlineprivate |
Definition at line 653 of file tpl_odhash.H.
|
inlineprivatenoexcept |
Undoes what allocate_bucket() or hard_allocate_bucket() did when they reserved bucket for key, which was never stored in it.
The probe counters are walked back with key, not with whatever the bucket holds.
Definition at line 319 of file tpl_odhash.H.
References Aleph::ODhashTable< Key, Cmp >::release_bucket().
|
inlinestaticprivate |
Definition at line 653 of file tpl_odhash.H.
Referenced by Aleph::ODhashTable< Key, Cmp >::stats().
|
friend |
Definition at line 1 of file tpl_odhash.H.
| Cmp Aleph::ODhashTable< Key, Cmp >::cmp |
Definition at line 270 of file tpl_odhash.H.
Referenced by Aleph::ODhashTable< Key, Cmp >::allocate_bucket(), Aleph::ODhashTable< Key, Cmp >::get_compare(), Aleph::ODhashTable< Key, Cmp >::get_compare(), Aleph::ODhashTable< Key, Cmp >::hard_allocate_bucket(), Aleph::ODhashTable< Key, Cmp >::remove_without_shrinking(), Aleph::ODhashTable< Key, Cmp >::search(), Aleph::ODhashTable< Key, Cmp >::stats(), and Aleph::ODhashTable< Key, Cmp >::swap().
|
private |
Definition at line 280 of file tpl_odhash.H.
Referenced by Aleph::ODhashTable< Key, Cmp >::allocate_bucket(), Aleph::ODhashTable< Key, Cmp >::decrease_probe_counter(), Aleph::ODhashTable< Key, Cmp >::release_bucket(), Aleph::ODhashTable< Key, Cmp >::stats(), and Aleph::ODhashTable< Key, Cmp >::swap().
| Hash_Fct Aleph::ODhashTable< Key, Cmp >::hash_fct = nullptr |
Definition at line 267 of file tpl_odhash.H.
Referenced by Aleph::ODhashTable< Key, Cmp >::allocate_bucket(), Aleph::ODhashTable< Key, Cmp >::hard_allocate_bucket(), Aleph::ODhashTable< Key, Cmp >::release_bucket(), Aleph::ODhashTable< Key, Cmp >::remove_without_shrinking(), Aleph::ODhashTable< Key, Cmp >::search(), Aleph::ODhashTable< Key, Cmp >::stats(), and Aleph::ODhashTable< Key, Cmp >::swap().
|
protected |
Definition at line 273 of file tpl_odhash.H.
Referenced by Aleph::ODhashTable< Key, Cmp >::ODhashTable(), Aleph::ODhashTable< Key, Cmp >::allocate_bucket(), Aleph::ODhashTable< Key, Cmp >::hard_allocate_bucket(), Aleph::ODhashTable< Key, Cmp >::index_backward(), Aleph::ODhashTable< Key, Cmp >::index_forward(), Aleph::ODhashTable< Key, Cmp >::is_key_in_table(), Aleph::ODhashTable< Key, Cmp >::is_valid_bucket(), Aleph::ODhashTable< Key, Cmp >::release_bucket(), Aleph::ODhashTable< Key, Cmp >::remove_without_shrinking(), Aleph::ODhashTable< Key, Cmp >::search(), Aleph::ODhashTable< Key, Cmp >::stats(), and Aleph::ODhashTable< Key, Cmp >::swap().
|
protected |
Definition at line 274 of file tpl_odhash.H.
Referenced by Aleph::ODhashTable< Key, Cmp >::swap().
|
private |
Definition at line 278 of file tpl_odhash.H.
Referenced by Aleph::ODhashTable< Key, Cmp >::allocate_bucket(), and Aleph::ODhashTable< Key, Cmp >::release_bucket().
| Hash_Fct Aleph::ODhashTable< Key, Cmp >::second_hash_fct = nullptr |
Definition at line 268 of file tpl_odhash.H.
Referenced by Aleph::ODhashTable< Key, Cmp >::allocate_bucket(), Aleph::ODhashTable< Key, Cmp >::get_second_hash_fct(), Aleph::ODhashTable< Key, Cmp >::hard_allocate_bucket(), Aleph::ODhashTable< Key, Cmp >::release_bucket(), Aleph::ODhashTable< Key, Cmp >::remove_without_shrinking(), Aleph::ODhashTable< Key, Cmp >::search(), Aleph::ODhashTable< Key, Cmp >::set_second_hash_fct(), Aleph::ODhashTable< Key, Cmp >::stats(), and Aleph::ODhashTable< Key, Cmp >::swap().
| Bucket* Aleph::ODhashTable< Key, Cmp >::table = nullptr |
Definition at line 266 of file tpl_odhash.H.
Referenced by Aleph::ODhashTable< Key, Cmp >::ODhashTable(), Aleph::ODhashTable< Key, Cmp >::ODhashTable(), Aleph::ODhashTable< Key, Cmp >::~ODhashTable(), Aleph::ODhashTable< Key, Cmp >::allocate_bucket(), Aleph::ODhashTable< Key, Cmp >::bucket_to_index(), Aleph::ODhashTable< Key, Cmp >::hard_allocate_bucket(), Aleph::ODhashTable< Key, Cmp >::is_key_in_table(), Aleph::ODhashTable< Key, Cmp >::is_valid_bucket(), Aleph::ODhashTable< Key, Cmp >::release_bucket(), Aleph::ODhashTable< Key, Cmp >::remove_without_shrinking(), Aleph::ODhashTable< Key, Cmp >::search(), Aleph::ODhashTable< Key, Cmp >::stats(), and Aleph::ODhashTable< Key, Cmp >::swap().
|
protected |
Definition at line 275 of file tpl_odhash.H.
Referenced by Aleph::ODhashTable< Key, Cmp >::swap().
|
private |
Definition at line 279 of file tpl_odhash.H.
Referenced by Aleph::ODhashTable< Key, Cmp >::swap().