79#ifndef __ADS_DialQueue
80 #define __ADS_DialQueue
113template<
class T , std::integral K = std::uint32_t ,
135 using Subject =
typename Policy::template bind< modifications , DialQueue >;
139 template<
class... O >
140 requires(
sizeof...( O ) > 0 )
161 void push(
const T & x , K k );
166 [[nodiscard]]
const T &
top(
void );
208 [[nodiscard]]
bool empty(
void )
const {
return( f_n == 0 ); }
211 [[nodiscard]] std::size_t
size(
void )
const {
return( f_n ); }
218 [[nodiscard]] std::size_t
window(
void )
const {
return( f_B.size() ); }
240 void extract( K theta , std::vector< T > & out );
253 requires( Subject::dynamic )
255 return( f_sub.attach( o ) );
261 requires( Subject::dynamic )
268 using U = std::make_unsigned_t< K >;
270 if constexpr( std::is_signed_v< K > )
271 return( U( k ) ^ ( U( 1 ) << ( std::numeric_limits< U >::digits - 1 ) ) );
276 static K decode( U u ) {
277 if constexpr( std::is_signed_v< K > )
278 return( K( u ^ ( U( 1 ) << ( std::numeric_limits< U >::digits - 1 ) ) ) );
284 void put(
const T & x , U u );
291 [[nodiscard]] std::size_t next(
void )
const;
295 [[nodiscard]]
bool counted(
void )
const;
297 using Ins = mod::Inserted< T , K >;
298 using Era = mod::Erased< T , K >;
302 static constexpr bool heard = Subject::template listened< E >;
305 void pushPlain(
const T & x , K k );
312 std::vector< std::vector< T > > f_B;
313 std::vector< std::uint64_t > f_bits;
315 std::size_t f_in = 0;
317 RadixHeap< T , U > f_over;
330#include "ADS/priority/impl/DialQueue.tpp"
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
The typed modifications, beyond the book: the vocabulary by which a structure tells the observers att...
A monotone priority queue of integer keys, beyond the book: the radix heap of Ahuja,...
T pop(void)
removes top() and returns it, in time if the overflow is not used
DialQueue(std::size_t c, O &... o)
an empty queue as DialQueue( c ), the static observers o...
typename Policy::template bind< modifications, DialQueue > Subject
the subject
Definition DialQueue.h:135
T Item
the type of the items
Definition DialQueue.h:120
K topKey(void)
the least key
mod::list< mod::Inserted< T, K >, mod::Erased< T, K >, mod::Cleared, mod::Rebuilt > modifications
the events: an item inserted or erased with its key, the queue emptied or rebuilt
Definition DialQueue.h:131
const T & top(void)
an item of least key, the last pushed among those of its bucket that did not come through the overflo...
void detach(int id)
detaches the observer number
Definition DialQueue.h:260
std::size_t size(void) const
the number of items,
Definition DialQueue.h:211
void clear(void)
removes the items, the buckets keeping their memory; any key may be pushed next
std::size_t window(void) const
the number of buckets of the window,
Definition DialQueue.h:218
bool empty(void) const
whether the queue has no item
Definition DialQueue.h:208
void push(const T &x, K k)
pushes with the key , in time if
int attach(O &o)
attaches the observer and gives its number
Definition DialQueue.h:252
Subject & subject(void)
the subject, for ADS::batch() and ADS::quiet()
Definition DialQueue.h:245
K Key
the type of the keys
Definition DialQueue.h:121
DialQueue(std::size_t c=1023)
an empty queue whose window has room for the keys up to above the last one extracted: buckets,...
K peekKey(void) const
the least key, which does not move : the keys pushed next need only be not smaller than the last one ...
void rebase(K k)
the keys pushed next may start from , the items placed again for , in time
const Subject & subject(void) const
the subject
Definition DialQueue.h:247
void extract(K theta, std::vector< T > &out)
every item of key at most appended to out, by increasing keys, each extracted as by pop()
#define ADS_COLD_PATH
a function of a rare path: never inlined, laid out away from the hot code
Definition Portable.h:107
#define ADS_NO_UNIQUE_ADDRESS
an empty member that takes no storage, by the attribute that does so (the standard one is accepted bu...
Definition Portable.h:81
std::string encode(const std::basic_string< C > &text, const std::map< C, std::string > &code)
the text encoded by the codes, the code of each character in turn
nobody listens: the subject is empty and every test is false at compile time, so that the structure c...
Definition Modification.h:1958
the structure emptied
Definition Modification.h:699
the item of handle , key and value erased, told before the removal outside a batch
Definition Modification.h:568
anything may have changed: forget and recompute
Definition Modification.h:708
a list of types, the events of a structure [see Modification.h]
Definition Modification.h:482