53#ifndef __ADS_PositionIndex
54 #define __ADS_PositionIndex
90template<
class T ,
class H = FastHash< const T * > >
99 static constexpr Position NONE = std::numeric_limits< Position >::max();
103 : f_table( n , std::move( h ) ) { }
125 template< std::ranges::random_access_range R >
158 [[nodiscard]] std::size_t
size(
void )
const {
return( f_table.size() ); }
161 [[nodiscard]]
bool empty(
void )
const {
return( f_table.empty() ); }
165 return( f_table.capacity() );
169 void reserve( std::size_t n ) { f_table.reserve( n ); }
172 void clear(
void ) { f_table.clear(); }
178 f_table.forEach( f );
183 f_table.swap( o.f_table );
184 f_words.swap( o.f_words );
185 f_drop.swap( o.f_drop );
197 FlatHashTable< const T * , Position , H > f_table;
198 std::vector< Word > f_words;
199 std::vector< const T * > f_drop;
211#include "ADS/dictionary/impl/PositionIndex.tpp"
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
The engineered hash functions of ADS, beyond the book [see HashFunctions.h for those of section 7....
A hash table with open addressing and control bytes, beyond the book: the engineered DICTIONARY of AD...
Position find(const T *p) const
the position of , NONE if absent
void clear(void)
removes all the keys, keeping the places
Definition PositionIndex.h:172
bool erase(const T *p)
removes ; false if it was absent
void swap(PositionIndex &o) noexcept
exchanges the contents with o in
Definition PositionIndex.h:182
std::size_t size(void) const
the number of keys
Definition PositionIndex.h:158
bool insert(const T *p, Position i)
gives the position ; true if was absent, false if its position was replaced
void assign(const R &v)
the index of the vector of pointers (any range with ): at the position , all the other keys gone
static constexpr Position NONE
the position of a key absent
Definition PositionIndex.h:99
void renumber(std::span< const Position > E)
the erasure of the positions from the vector: the keys at a position in go away,...
bool empty(void) const
true if there are no keys
Definition PositionIndex.h:161
std::uint32_t Position
the type of the positions
Definition PositionIndex.h:96
PositionIndex(std::size_t n=0, H h=H())
an empty index with room for keys
Definition PositionIndex.h:102
std::size_t capacity(void) const
the number of places of the table
Definition PositionIndex.h:164
void reserve(std::size_t n)
room for keys with no rebuild
Definition PositionIndex.h:169
void forEach(F &&f) const
f( p , i ) for each key at the position , in the order of the places
Definition PositionIndex.h:177
bool contains(const T *p) const
true if is in the index
std::uint64_t Word
a word of 64 bits
Definition Bitwise.h:73