48#ifndef __ADS_KnuthHashing
49 #define __ADS_KnuthHashing
77template<
class K ,
class V ,
class H = std::hash< K > >
90 [[nodiscard]] std::optional< V >
lookup(
const K & k )
const;
117 void insert(
const K & k ,
const V & v );
120 [[nodiscard]] std::size_t
size(
void )
const;
123 [[nodiscard]] std::size_t
probes(
void )
const;
134 static std::size_t
size(
const auto & o ) {
return( o.f_T.size() ); }
136 static bool occupied(
const auto & o , std::size_t i ) {
137 return( o.f_T[ i ].used );
140 static auto read(
const auto & o , std::size_t i ) {
189 [[nodiscard]]
bool listed(
void )
const;
191 std::vector< Slot > f_T;
194 std::size_t f_size = 0;
195 mutable std::size_t f_probes = 0;
205template<
class K ,
class V ,
class H = std::hash< K > >
218 [[nodiscard]] std::optional< V >
lookup(
const K & k )
const;
247 void insert(
const K & k ,
const V & v );
250 [[nodiscard]] std::size_t
size(
void )
const;
253 [[nodiscard]] std::size_t
probes(
void )
const;
264 static std::size_t
size(
const auto & o ) {
return( o.f_T.size() ); }
266 static bool occupied(
const auto & o , std::size_t i ) {
267 return( o.f_T[ i ].has_value() );
270 static const std::pair< K , V > &
read(
const auto & o , std::size_t i ) {
271 return( *o.f_T[ i ] );
310 [[nodiscard]] std::size_t at(
const K & k , std::size_t i )
const;
313 std::vector< std::optional< std::pair< K , V > > > f_T;
314 std::size_t f_size = 0;
315 mutable std::size_t f_probes = 0;
328#include "ADS/dictionary/impl/KnuthHashing.tpp"
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
The iterators that the containers of the library have in common, beyond the book: they give a contain...
std::size_t size_type
the type of the sizes
Definition KnuthHashing.h:282
const std::pair< K, V > & reference
a reference to an item
Definition KnuthHashing.h:286
void insert(const K &k, const V &v)
associates to
const_iterator cbegin(void) const
the constant iterator on the first item
Definition KnuthHashing.h:303
std::size_t probes(void) const
the places examined by the last lookup()
BrentHashTable(std::size_t m, H h=H())
a table of places
const_iterator iterator
the iterator on the items
Definition KnuthHashing.h:292
K key_type
the type of the keys
Definition KnuthHashing.h:278
const_iterator cend(void) const
the constant iterator past the last item
Definition KnuthHashing.h:305
std::optional< V > lookup(const K &k) const
the value of the key , or nothing, along the places of its inspection up to an empty one
std::pair< K, V > value_type
the type of the items, for the standard library
Definition KnuthHashing.h:276
SlotIterator< BrentHashTable, Places > const_iterator
the iterator on the items, constant
Definition KnuthHashing.h:290
V mapped_type
the type of the values
Definition KnuthHashing.h:280
const std::pair< K, V > & const_reference
a constant reference to an item
Definition KnuthHashing.h:288
const_iterator end(void) const
the iterator past the last item
Definition KnuthHashing.h:299
std::size_t size(void) const
the number of keys
std::ptrdiff_t difference_type
the type of the distances between two iterators
Definition KnuthHashing.h:284
const_iterator begin(void) const
the iterator on the first item
Definition KnuthHashing.h:295
const_iterator begin(void) const
the iterator on the first item
Definition KnuthHashing.h:166
std::size_t size_type
the type of the sizes
Definition KnuthHashing.h:153
void insert(const K &k, const V &v)
associates to
std::pair< K, V > value_type
the type of the items, for the standard library
Definition KnuthHashing.h:147
PairRef< const K &, const V & > const_reference
a constant reference to an item
Definition KnuthHashing.h:159
const_iterator cend(void) const
the constant iterator past the last item
Definition KnuthHashing.h:176
const_iterator cbegin(void) const
the constant iterator on the first item
Definition KnuthHashing.h:174
const_iterator iterator
the iterator on the items
Definition KnuthHashing.h:163
SlotIterator< CoalescedHashTable, Places > const_iterator
the iterator on the items, constant
Definition KnuthHashing.h:161
std::size_t probes(void) const
the places examined by the last lookup() or insert()
V mapped_type
the type of the values
Definition KnuthHashing.h:151
std::ptrdiff_t difference_type
the type of the distances between two iterators
Definition KnuthHashing.h:155
CoalescedHashTable(std::size_t m, std::size_t cellar=0, H h=H())
a table of places addressed by the hash and of cellar more
std::size_t size(void) const
the number of keys
const_iterator end(void) const
the iterator past the last item
Definition KnuthHashing.h:170
PairRef< const K &, const V & > reference
a reference to an item
Definition KnuthHashing.h:157
std::optional< V > lookup(const K &k) const
the value of the key , or nothing, along the list of the place
K key_type
the type of the keys
Definition KnuthHashing.h:149
a bidirectional iterator on the occupied places of the table O, by the policy P with the static funct...
Definition Iterators.h:691
std::conditional_t< detail::plainPair< A, B, VA, VB >, std::pair< A, B >, detail::PairProxy< A, B, VA, VB > > PairRef
the pair that an iterator reads by value, in general two references into the container,...
Definition Iterators.h:648
the places of the table, for SlotIterator
Definition KnuthHashing.h:262
static bool occupied(const auto &o, std::size_t i)
whether the place holds a key
Definition KnuthHashing.h:266
static std::size_t size(const auto &o)
the number of places
Definition KnuthHashing.h:264
static const std::pair< K, V > & read(const auto &o, std::size_t i)
the pair of the place
Definition KnuthHashing.h:270
the places of the table, for SlotIterator
Definition KnuthHashing.h:132
static auto read(const auto &o, std::size_t i)
the pair of the place
Definition KnuthHashing.h:140
static bool occupied(const auto &o, std::size_t i)
whether the place holds a key
Definition KnuthHashing.h:136
static std::size_t size(const auto &o)
the number of places
Definition KnuthHashing.h:134