53# ifndef TPL_DYNARRAYHEAP_H
54# define TPL_DYNARRAYHEAP_H
74 template <
typename T,
class Compare>
78 for (
size_t p, i =
r; i >
l; i = p)
102 template <
typename T,
class Compare>
117 T *
ac = &a.access(c);
120 T *
ac1 = &a.access(c + 1);
128 T &
ai = a.access(i);
146 template <
typename T,
class Compare = Aleph::less<T>>
159 static size_t r_index(
const size_t & i)
noexcept
188 return array.access(1);
196 return array.access(1);
211 return array.access(pos);
223 return array.access(pos);
244 return array.access(pos);
252 return array.access(pos);
318 if (
h.num_items != 0)
338 template <
class Operation>
347 template <
class Operation>
353 template <
class Operation>
359 template <
class Operation>
#define Args_Ctor(Name, Type)
C++20 concepts hub: comparison, BST policy, and Aleph container concepts.
Exception handling system with formatted messages for Aleph-w.
#define ah_out_of_range_error_if(C)
Throws std::out_of_range if condition holds.
#define ah_underflow_error_if(C)
Throws std::underflow_error if condition holds.
#define Special_Ctors(Set_Type, Type)
Generates special constructors for containers.
Dynamic heap (priority queue) backed by DynArray.
T & insert_direct(T &&key)
Move overload of insert_direct().
static size_t r_index(const size_t &i) noexcept
DynArrayHeap(Compare cmp_fct=Compare())
Default constructor.
T & put(T &&key)
Alias for insert() (move overload).
void reserve(size_t n)
Ensure the underlying array has capacity for at least n elements.
constexpr bool is_empty() const noexcept
Return true if the heap is empty.
T getMin()
Remove and return the top element.
bool traverse(Operation &operation)
Traverse all elements in the heap.
T & put(const T &key)
Alias for insert().
bool traverse(Operation &operation) const
T & append(const T &key)
Alias for insert().
bool traverse(Operation &&operation=Operation()) const
T & insert(const T &key)
Insert a copy of key into the heap.
bool traverse(Operation &&operation=Operation())
T & insert(T &&key)
Insert a key by moving it into the heap.
T & top()
Return the element with highest priority (the heap top).
T & insert_direct(const T &key)
Insert by directly indexing into the backing array.
const T & top() const
Const overload of top().
T & append(T &&key)
Alias for insert() (move overload).
constexpr size_t size() const noexcept
Return the number of elements.
Iterator on the items of array.
void next_ne() noexcept
Move the iterator one position forward guaranteeing no exception.
size_t size() const noexcept
Return the current dimension of array.
Equality test for containers.
Common methods to the Aleph-w ( ) containers.
and
Conditional mapping of the elements of the container.
Common sequential searching methods on containers.
Mixin that adds STL begin()/end() and cbegin()/cend() to Aleph containers.
int cmp(const __gmp_expr< T, U > &expr1, const __gmp_expr< V, W > &expr2)
size_t blossom_maximum_cardinality_matching(const GT &g, DynDlist< typename GT::Arc * > &matching, SA sa=SA())
Alias of compute_maximum_cardinality_general_matching().
Main namespace for Aleph-w library functions.
size_t l_index(const size_t i)
Map a binary heap index to the index of its left child.
void sift_down(T *ptr, const size_t l, const size_t r, Compare &cmp)
Restore the heap property by moving the element at position l downwards.
std::decay_t< typename HeadC::Item_Type > T
size_t u_index(const size_t &i)
Map a binary heap index to the index of its parent.
T & sift_up(T *ptr, const size_t l, const size_t r, Compare &cmp)
Restore the heap property by moving the element at position r upwards.
typename DynArray< T >::Iterator Base
bool has_curr() const noexcept
Iterator(const DynArrayHeap &h) noexcept
long get_pos() const noexcept
Generic list of items stored in a container.
Lazy and scalable dynamic array implementation.