63#ifndef __ADS_FibonacciHeapPriorityQueue
64 #define __ADS_FibonacciHeapPriorityQueue
98template<
class T , std::totally_ordered P = int ,
127 : f_pool( std::size_t( 1 ) << 24 ,
151 [[nodiscard]]
bool empty(
void )
const;
154 [[nodiscard]]
int size(
void )
const;
158 [[nodiscard]]
const T &
min(
void )
const;
293 return(
reference( f_x->priority , f_x->value ) );
304 if( f_x->right != first ) {
322 return( f_x == o.f_x );
326 const Node * f_x =
nullptr;
327 const Node * f_min =
nullptr;
359 static void unlink( Node * x );
362 static void splice( Node * x , Node * y );
365 static void remove( Node * x , Node *& head );
367 void add_root( Node * z );
370 void cut( Node * x , Node * y );
374 void consolidate( Node * w );
377 [[nodiscard]]
bool owns(
const Node * x )
const;
382 [[nodiscard]]
bool tree(
const Node * x ,
const Node * parent ,
387 [[nodiscard]]
bool isHeap(
void )
const;
389 Node * f_min =
nullptr;
400template<
class T , std::totally_ordered P ,
class A >
412#include "ADS/priority/impl/FibonacciHeapPriorityQueue.tpp"
The rules of the allocator-aware containers of the standard ([container.reqmts], [allocator....
The capabilities of the structures, beyond the book: what an algorithm may ask of its argument to cho...
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.
the iterator of the view, constant, forward
Definition FibonacciHeapPriorityQueue.h:270
reference operator*(void) const
the priority and the item of the node
Definition FibonacciHeapPriorityQueue.h:292
std::input_iterator_tag iterator_category
an input iterator for the older algorithms, since reference is not a reference
Definition FibonacciHeapPriorityQueue.h:283
std::ptrdiff_t difference_type
the type of the distances between iterators
Definition FibonacciHeapPriorityQueue.h:278
std::forward_iterator_tag iterator_concept
a forward iterator for the concepts of C++20
Definition FibonacciHeapPriorityQueue.h:280
bool operator==(const const_iterator &o) const
whether the two iterators are on the same node
Definition FibonacciHeapPriorityQueue.h:321
std::pair< P, T > value_type
the type of the items of the view
Definition FibonacciHeapPriorityQueue.h:276
const_iterator(const Node *min)
the first node of the view, the root
Definition FibonacciHeapPriorityQueue.h:289
const_iterator & operator++(void)
the next node in preorder
Definition FibonacciHeapPriorityQueue.h:297
const_iterator operator++(int)
the next node in preorder, returning the iterator before the step
Definition FibonacciHeapPriorityQueue.h:314
PairRef< const P &, const T & > reference
the pair of the priority and of the item of a node the type of a reference to an item of the view
Definition FibonacciHeapPriorityQueue.h:274
const_iterator(void)=default
the end of the view
Node * Handle
what insert() gives
Definition FibonacciHeapPriorityQueue.h:120
T Item
the type of the items
Definition FibonacciHeapPriorityQueue.h:118
FibonacciHeapPriorityQueue(const FibonacciHeapPriorityQueue &)=delete
no copy: the handles point into the heap
const_iterator iterator
the same as const_iterator
Definition FibonacciHeapPriorityQueue.h:341
const_iterator cbegin(void) const
the same as begin()
Definition FibonacciHeapPriorityQueue.h:352
FibonacciHeapPriorityQueue(const A &alloc)
the empty queue, the blocks of its nodes from alloc
Definition FibonacciHeapPriorityQueue.h:126
Handle insert(const T &x, const P &p)
inserts with the priority and gives its handle, a tree of one node among the roots,...
allocator_type get_allocator(void) const
the allocator of the blocks of the nodes
Definition FibonacciHeapPriorityQueue.h:133
std::ptrdiff_t difference_type
the type of the distances between iterators
Definition FibonacciHeapPriorityQueue.h:335
std::pair< P, T > value_type
the type of the items of the view
Definition FibonacciHeapPriorityQueue.h:331
FibonacciHeapPriorityQueue(void)=default
the empty heap
const T & min(void) const
the item of smallest priority, the least of the roots
PairRef< const P &, const T & > reference
the type of a reference to an item of the view
Definition FibonacciHeapPriorityQueue.h:337
bool empty(void) const
whether the heap has no item
A allocator_type
the type of the allocator
Definition FibonacciHeapPriorityQueue.h:131
~FibonacciHeapPriorityQueue()
the heap and its nodes destroyed
const_iterator end(void) const
the end of the view
Definition FibonacciHeapPriorityQueue.h:348
void decrease(Handle x, const P &p)
lowers to the priority of the node , in amortized time
int size(void) const
the number of items,
reference const_reference
the type of a constant reference to an item
Definition FibonacciHeapPriorityQueue.h:339
const_iterator cend(void) const
the same as end()
Definition FibonacciHeapPriorityQueue.h:354
std::size_t size_type
the type of the sizes
Definition FibonacciHeapPriorityQueue.h:333
T deleteMin(void)
removes the item of smallest priority and returns it, in amortized time; the handle of the item is n...
FibonacciHeapPriorityQueue & operator=(const FibonacciHeapPriorityQueue &)=delete
no copy: the handles point into the heap
const_iterator begin(void) const
the first item of the view
Definition FibonacciHeapPriorityQueue.h:344
FibonacciHeapPriorityQueue(FibonacciHeapPriorityQueue &&other) noexcept
the items of other, which is left empty; its handles stay valid here
P Priority
the type of the priorities
Definition FibonacciHeapPriorityQueue.h:119
const P & minPriority(void) const
the smallest priority
an allocator of objects of type T, on huge pages for the large blocks
Definition HugePageAllocator.h:169
a pool of objects of type T in blocks of at most slots
Definition ObjectPool.h:108
constexpr bool enable_stable_references
whether the items of S keep their addresses while they are in it, so that a handle may be a pointer a...
Definition Capabilities.h:203
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
a node of the heap
Definition FibonacciHeapPriorityQueue.h:107
T value
the item
Definition FibonacciHeapPriorityQueue.h:109
Node * right
the next node of its circular list
Definition FibonacciHeapPriorityQueue.h:113
Node * parent
the parent, nullptr for a root
Definition FibonacciHeapPriorityQueue.h:110
Node * child
a child, the entry of their circular list
Definition FibonacciHeapPriorityQueue.h:111
int degree
the number of children
Definition FibonacciHeapPriorityQueue.h:114
Node * left
the previous node of its circular list
Definition FibonacciHeapPriorityQueue.h:112
bool mark
whether it lost a child since it became one
Definition FibonacciHeapPriorityQueue.h:115
P priority
the priority
Definition FibonacciHeapPriorityQueue.h:108