57#ifndef __ADS_YFastTrie
58 #define __ADS_YFastTrie
90template< std::unsigned_integral U ,
class V = std::monostate ,
91 int W = std::numeric_limits< U >::digits >
139 [[nodiscard]]
const U *
find( U x )
const;
143 [[nodiscard]] std::optional< V >
lookup( U x )
const;
196 [[nodiscard]] std::size_t
size(
void )
const {
return( f_n ); }
199 [[nodiscard]]
bool empty(
void )
const {
return( f_n == 0 ); }
202 [[nodiscard]] std::size_t
groups(
void )
const {
return( f_x.size() ); }
213 static constexpr U TOP = ( W == std::numeric_limits< U >::digits )
214 ? std::numeric_limits< U >::max()
215 : U( ( U( 1 ) << W ) - 1 );
219 [[nodiscard]]
static const U * ceiling(
const Group & T , U x );
223 [[nodiscard]]
bool consistent(
void )
const;
239#include "ADS/dictionary/impl/YFastTrie.tpp"
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
Hashing with random tables, beyond the book:
The treap of Seidel and Aragon, beyond the book: a binary search tree on the keys that is also a heap...
The x-fast tries of Willard, beyond the book: SORTED SETs of the integers of bits,...
the generator SplitMix64, a UniformRandomBitGenerator
Definition RandomHashing.h:122
a DICTIONARY on a treap, with the operations based on join [see Joinable]
Definition Treap.h:111
the x-fast trie: a binary trie with a hash table of the prefixes per depth
Definition XFastTrie.h:124
std::size_t groups(void) const
the number of groups, the last one included
Definition YFastTrie.h:202
YFastTrie(std::uint64_t seed=1)
the empty trie, its coins drawn from the seed
std::optional< V > lookup(U x) const
the value of , or nothing
bool insert(U x, const V &v=V())
associates to ; true if was not there, in expected amortized time
YFastTrie(const YFastTrie &)=delete
void forEach(F &&f) const
f( x , v ) on the pairs by increasing keys
~YFastTrie()
frees the groups
YFastTrie & operator=(const YFastTrie &)=delete
bool empty(void) const
true if there are no keys
Definition YFastTrie.h:199
U Item
the items of the SSet, the keys
Definition YFastTrie.h:99
const U * lowerBound(U x) const
the smallest key , nil if none (the find( x ) of the SSet of Morin's book), in expected time
const U * find(U x) const
the key , nil if it is not there, in expected time
YFastTrie(YFastTrie &&o)
the trie of o, which is left empty
U Key
the type of the keys
Definition YFastTrie.h:98
bool remove(U x)
removes ; true if it was there, in expected amortized time
YFastTrie & operator=(YFastTrie &&o) noexcept
the trie of o, which gets the keys of this one
bool contains(U x) const
true if is there
V Value
the type of the values
Definition YFastTrie.h:100
std::size_t size(void) const
the number of keys
Definition YFastTrie.h:196
a monoid with the inverse G::inverse( a ), i.e., combine( inverse( a) , a ) and combine( a ,...
Definition Algebra.h:130
the number of bits of the keys of a trie on U: , if it is between 1 and the bits of U
Definition BinaryTrie.h:103