54#ifndef __ADS_LinkedHeapPriorityQueue
55 #define __ADS_LinkedHeapPriorityQueue
85template<
class T , std::totally_ordered P =
int ,
bool L = false >
115 [[nodiscard]]
bool empty(
void )
const;
118 [[nodiscard]]
int size(
void )
const;
122 [[nodiscard]]
const T &
min(
void )
const;
173 void insert(
const T & x ,
const P & p );
213 Node *left = nullptr ,
217 Node(
const P & p ,
const T & v , Node * u )
218 : priority( p ) , value( v ) , parent( u ) { }
231 static auto root(
const auto & o ) {
232 return(
static_cast< const Node *
>( o.f_root ) );
235 static auto left(
const auto * n ) {
236 return(
static_cast< const Node *
>( n->left ) );
239 static auto right(
const auto * n ) {
240 return(
static_cast< const Node *
>( n->right ) );
243 static auto read(
const auto * n ) {
278 Node * at(
int k )
const;
280 static void swap_contents( Node * a , Node * b );
284 [[nodiscard]]
bool shaped(
const Node * u ,
int k ,
int & n )
const;
288 [[nodiscard]]
bool isHeap(
void )
const;
292 [[nodiscard]] Node * nextParent(
void )
const;
296 [[nodiscard]] Node * previousLeaf(
void )
const;
299 void release( Node * u );
301 Node * f_root =
nullptr;
302 Node * f_last =
nullptr;
316#include "ADS/priority/impl/LinkedHeapPriorityQueue.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...
A pool of objects of one type, beyond the book: make() builds an object in a slot of the pool and fre...
The PRIORITYQUEUE of section 10.1, with decreasing priority, in two concepts.
const_iterator end(void) const
the end of the view
Definition LinkedHeapPriorityQueue.h:268
std::ptrdiff_t difference_type
the type of the distances between iterators
Definition LinkedHeapPriorityQueue.h:253
const_iterator begin(void) const
the first item of the view
Definition LinkedHeapPriorityQueue.h:264
LinkedHeapPriorityQueue(const LinkedHeapPriorityQueue &)=delete
no copy: the nodes belong to the queue
const_iterator iterator
the same as const_iterator
Definition LinkedHeapPriorityQueue.h:261
PairRef< const P &, const T & > reference
the type of a reference to an item of the view
Definition LinkedHeapPriorityQueue.h:255
T Item
the type of the items
Definition LinkedHeapPriorityQueue.h:91
const T & min(void) const
the item of smallest priority, at the root
const P & minPriority(void) const
the smallest priority
const_iterator cbegin(void) const
the same as begin()
Definition LinkedHeapPriorityQueue.h:272
bool empty(void) const
whether the queue has no item
LinkedHeapPriorityQueue(void)=default
the empty queue
int size(void) const
the number of items,
LinkedHeapPriorityQueue & operator=(const LinkedHeapPriorityQueue &)=delete
no copy: the nodes belong to the queue
LinkedHeapPriorityQueue(LinkedHeapPriorityQueue &&other) noexcept
the items of other, which is left empty
reference const_reference
the type of a constant reference to an item
Definition LinkedHeapPriorityQueue.h:257
PathIterator< LinkedHeapPriorityQueue, Shape > const_iterator
the iterator of the view, constant
Definition LinkedHeapPriorityQueue.h:259
void insert(const T &x, const P &p)
inserts with the priority , a new last leaf moved up while smaller than its parent,...
LinkedHeapPriorityQueue & operator=(LinkedHeapPriorityQueue &&other) noexcept
the items of other, which is left empty, in place of these
std::pair< P, T > value_type
the type of the items of the view
Definition LinkedHeapPriorityQueue.h:249
const_iterator cend(void) const
the same as end()
Definition LinkedHeapPriorityQueue.h:274
T deleteMin(void)
removes the item of smallest priority and returns it, the last leaf moved into the root and down whil...
std::size_t size_type
the type of the sizes
Definition LinkedHeapPriorityQueue.h:251
~LinkedHeapPriorityQueue()
the queue and its nodes destroyed
P Priority
the type of the priorities
Definition LinkedHeapPriorityQueue.h:92
a bidirectional iterator on the nodes of a binary tree of the owner O in symmetric order,...
Definition Iterators.h:867
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 shape of the tree, for PathIterator
Definition LinkedHeapPriorityQueue.h:229
static auto left(const auto *n)
the left child of the node
Definition LinkedHeapPriorityQueue.h:235
static auto read(const auto *n)
the priority and the item of the node
Definition LinkedHeapPriorityQueue.h:243
static auto root(const auto &o)
the root of the queue
Definition LinkedHeapPriorityQueue.h:231
static auto right(const auto *n)
the right child of the node
Definition LinkedHeapPriorityQueue.h:239