Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::DynArrayHeap< T, Compare > Class Template Reference

Dynamic heap (priority queue) backed by DynArray. More...

#include <tpl_dynArrayHeap.H>

Inheritance diagram for Aleph::DynArrayHeap< T, Compare >:
[legend]
Collaboration diagram for Aleph::DynArrayHeap< T, Compare >:
[legend]

Classes

struct  Iterator
 

Public Types

using Item_Type = T
 
- Public Types inherited from StlAlephIterator< SetName >
using iterator = StlIterator< SetName >
 
using const_iterator = StlConstIterator< SetName >
 

Public Member Functions

 DynArrayHeap (Compare cmp_fct=Compare())
 Default constructor.
 
template<template< typename > class List>
 DynArrayHeap (const List< T > &l)
 
template<class It >
 DynArrayHeap (It b, It e)
 
 DynArrayHeap (std::initializer_list< T > l)
 
template<typename ... Args>
 DynArrayHeap (const T &item, Args &... args)
 
template<typename ... Args>
 DynArrayHeap (T &&item, Args &... args)
 
T & top ()
 Return the element with highest priority (the heap top).
 
const T & top () const
 Const overload of top().
 
T & insert (const T &key)
 Insert a copy of key into the heap.
 
T & insert (T &&key)
 Insert a key by moving it into the heap.
 
void reserve (size_t n)
 Ensure the underlying array has capacity for at least n elements.
 
T & insert_direct (const T &key)
 Insert by directly indexing into the backing array.
 
T & insert_direct (T &&key)
 Move overload of insert_direct().
 
T & put (const T &key)
 Alias for insert().
 
T & put (T &&key)
 Alias for insert() (move overload).
 
T & append (const T &key)
 Alias for insert().
 
T & append (T &&key)
 Alias for insert() (move overload).
 
T getMin ()
 Remove and return the top element.
 
T get ()
 
T getMax ()
 
constexpr size_t size () const noexcept
 Return the number of elements.
 
constexpr bool is_empty () const noexcept
 Return true if the heap is empty.
 
template<class Operation >
bool traverse (Operation &operation)
 Traverse all elements in the heap.
 
template<class Operation >
bool traverse (Operation &operation) const
 
template<class Operation >
bool traverse (Operation &&operation=Operation()) const
 
template<class Operation >
bool traverse (Operation &&operation=Operation())
 
- Public Member Functions inherited from LocateFunctions< Container, Type >
auto get_it () const
 Return a properly initialized iterator positioned at the first item on the container.
 
auto get_it (const size_t pos) const
 Return a properly initialized iterator positioned at the pos item on the container.
 
auto get_itor () const
 Alias of get_it().
 
Type & nth_ne (const size_t n) noexcept
 Return the n‑th element without bounds checking.
 
const Type & nth_ne (const size_t n) const noexcept
 Const overload of nth_ne(size_t).
 
Type & nth (const size_t n)
 Return the n-th item of the container.
 
const Type & nth (const size_t n) const
 Const overload of nth(size_t).
 
template<class Operation >
requires Aleph::PredicateWith<Operation &, Type &>
Type * find_ptr (Operation &operation) noexcept(operation_is_noexcept< Operation >())
 Find a pointer to an item in the container according to a searching criterion.
 
template<class Operation >
requires Aleph::PredicateWith<Operation &, Type &>
const Type * find_ptr (Operation &operation) const noexcept(operation_is_noexcept< Operation >())
 Const overload of find_ptr(Operation&).
 
template<class Operation >
requires Aleph::PredicateWith<Operation &, Type &>
const Type * find_ptr (Operation &&operation) const noexcept(operation_is_noexcept< Operation >())
 Overload of find_ptr() const that accepts rvalues.
 
template<class Operation >
requires Aleph::PredicateWith<Operation &, Type &>
Type * find_ptr (Operation &&operation) noexcept(operation_is_noexcept< Operation >())
 Overload of find_ptr() that accepts rvalues.
 
template<class Operation >
requires Aleph::PredicateWith<Operation &, const Type &>
size_t find_index (Operation &operation) const noexcept(operation_is_noexcept< Operation >())
 Find the position of an item in the container according to a searching criterion.
 
template<class Operation >
requires Aleph::PredicateWith<Operation &, const Type &>
size_t find_index (Operation &&operation) const noexcept(operation_is_noexcept< Operation >())
 Overload of find_index() that accepts rvalues.
 
template<class Operation >
requires Aleph::PredicateWith<Operation &, Type &>
std::tuple< bool, Type > find_item (Operation &operation) noexcept(operation_is_noexcept< Operation >())
 Safe sequential searching of an item matching a criterion.
 
template<class Operation >
requires Aleph::PredicateWith<Operation &, Type &>
std::tuple< bool, Type > find_item (Operation &operation) const noexcept(operation_is_noexcept< Operation >())
 
template<class Operation >
requires Aleph::PredicateWith<Operation &, Type &>
std::tuple< bool, Type > find_item (Operation &&operation) noexcept(operation_is_noexcept< Operation >())
 Overload of find_item() that accepts rvalues.
 
template<class Operation >
requires Aleph::PredicateWith<Operation &, Type &>
std::tuple< bool, Type > find_item (Operation &&operation) const noexcept(operation_is_noexcept< Operation >())
 Overload of find_item() const that accepts rvalues.
 
template<class Operation >
requires Aleph::PredicateWith<Operation &, Type &>
bool contains_if (Operation &&operation) const noexcept(operation_is_noexcept< Operation >())
 Test if an item satisfying a criterion is present in the container.
 
bool contains (const Type &item) const
 Test if an item is present in the container using equality.
 
- Public Member Functions inherited from FunctionalMethods< Container, T >
template<typename... Args>
void emplace (Args &&...args)
 Appends a new element into the container by constructing it in-place with the given args.
 
template<typename... Args>
void emplace_end (Args &&...args)
 
template<typename... Args>
void emplace_ins (Args &&...args)
 Insert a new element into the container by constructing it in-place with the given args.
 
template<typename... Args>
size_t ninsert (Args... args)
 Insert n variadic items.
 
template<typename... Args>
size_t nappend (Args... args)
 Append n variadic items.
 
template<class Operation >
requires Aleph::CallableWith<Operation &, const T &>
void for_each (Operation &operation)
 Traverse all the container and performs an operation on each element.
 
template<class Operation >
requires Aleph::CallableWith<Operation &, const T &>
void for_each (Operation &operation) const
 Const overload of for_each(Operation&).
 
template<class Operation >
requires Aleph::CallableWith<Operation &, const T &>
void for_each (Operation &&operation) const
 Overload of for_each() const that accepts rvalues.
 
template<class Operation >
requires Aleph::CallableWith<Operation &, const T &>
void for_each (Operation &&operation)
 Overload of for_each() that accepts rvalues.
 
template<class Operation >
requires Aleph::CallableWith<Operation &, const T &>
void each (Operation &operation)
 Alias of for_each(Operation&).
 
template<class Operation >
requires Aleph::CallableWith<Operation &, const T &>
void each (Operation &operation) const
 Const alias of for_each(Operation&).
 
template<class Operation >
requires Aleph::CallableWith<Operation &, const T &>
void each (Operation &&operation) const
 Const alias of each() that accepts rvalues.
 
template<class Operation >
requires Aleph::CallableWith<Operation &, const T &>
void each (Operation &&operation)
 Alias of each() that accepts rvalues.
 
template<class Operation >
void each (size_t pos, const size_t slice, Operation &operation) const
 Traverse the container starting at pos taking one item every slice, performing a mutable operation on each visited element.
 
template<class Operation >
void each (const size_t pos, const size_t slice, Operation &&operation) const
 
template<class Operation >
requires Aleph::CallableWith<Operation &, T &>
void mutable_for_each (Operation &operation)
 Apply a mutable operation to each element of the container.
 
template<class Operation >
requires Aleph::CallableWith<Operation &, T &>
void mutable_for_each (Operation &&operation)
 
template<class Operation >
requires requires(const typename Aleph::concepts_detail::defer<Container, Operation>::type &c, Operation &op) { { c.traverse(op) } -> std::convertible_to<bool>; }
bool all (Operation &operation) const
 Check if all the elements of the container satisfy a condition.
 
template<class Operation >
requires requires(const typename Aleph::concepts_detail::defer<Container, Operation>::type &c, Operation &op) { { c.traverse(op) } -> std::convertible_to<bool>; }
bool all (Operation &&operation) const
 Overload of all() that accepts rvalues.
 
template<class Operation >
requires Aleph::PredicateWith<Operation &, const T &>
bool exists (Operation &op) const
 Test for existence in the container of an element satisfying a criterion.
 
template<class Operation >
requires Aleph::PredicateWith<Operation &, const T &>
bool exists (Operation &&op) const
 Overload of exists() that accepts rvalues.
 
template<typename __T = T, class Operation = Aleph::Dft_Map_Op<T, __T>>
requires requires(Aleph::DynList<__T> &l, Operation &op, const T &item) { l.append(op(item)); }
Aleph::DynList< __T > maps (Operation &op) const
 Map the elements of the container.
 
template<typename __T = T, class Operation = Aleph::Dft_Map_Op<__T, __T>>
requires requires(Aleph::DynList<__T> &l, Operation &op, const T &item) { l.append(op(item)); }
Aleph::DynList< __T > maps (Operation &&op) const
 Overload of maps() that accepts rvalues.
 
Aleph::DynList< __T > maps_if (Prop prop, Operation &op) const
 
Aleph::DynList< __T > maps_if (Prop prop, Operation &&op) const
 
template<typename __T = T, class Operation = Aleph::Dft_Map_Op<T, __T>>
requires requires(Aleph::DynList<__T> &l, Operation &op, const T &item) { l.append(op(item)); }
Aleph::DynList< __T > map (Operation &op) const
 Synonym of maps().
 
template<typename __T = T, class Operation = Aleph::Dft_Map_Op<__T, __T>>
requires requires(Aleph::DynList<__T> &l, Operation &op, const T &item) { l.append(op(item)); }
Aleph::DynList< __T > map (Operation &&op) const
 Overload of map() that accepts rvalues.
 
Aleph::DynList< __T > map_if (Prop prop, Operation &op) const
 
Aleph::DynList< __T > map_if (Prop prop, Operation &&op) const
 
Aleph::DynList< T > to_dynlist () const
 Convert container to DynList.
 
std::vector< T > to_vector () const
 Convert container to std::vector.
 
template<typename __T = T, class Op = Aleph::Dft_Fold_Op<__T, T>>
requires requires(__T &acc, Op &op, const T &item) { acc = op(acc, item); }
__T foldl (const __T &init, Op &op) const
 Fold the elements of the container to a specific result.
 
template<typename __T = T, class Op = Aleph::Dft_Fold_Op<__T, T>>
requires requires(__T &acc, Op &op, const T &item) { acc = op(acc, item); }
__T foldl (const __T &init, Op &&op=Op()) const
 Overload of foldl() that accepts rvalues.
 
template<typename __T = T, class Op = Aleph::Dft_Fold_Op<__T, T>>
requires requires(__T &acc, Op &op, const T &item) { acc = op(acc, item); }
__T fold_left (const __T &init, Op &op) const
 Alias for foldl with the same accumulator type.
 
template<typename __T = T, class Op = Aleph::Dft_Fold_Op<__T, T>>
requires requires(__T &acc, Op &op, const T &item) { acc = op(acc, item); }
__T fold_left (const __T &init, Op &&op=Op()) const
 Overload of fold_left() that accepts rvalues.
 
template<class Operation >
requires requires(T &acc, Operation &op, const T &item) { acc = op(acc, item); }
T fold (const T &init, Operation &operation) const
 Simplified version of foldl() where the folded type is the same type of elements stored in the container.
 
template<class Operation >
requires requires(T &acc, Operation &op, const T &item) { acc = op(acc, item); }
T fold (const T &init, Operation &&operation) const
 Overload of fold() that accepts rvalues.
 
template<class Operation >
requires Aleph::PredicateWith<Operation &, const T &>
Aleph::DynList< T > filter (Operation &operation) const
 Filter the elements of a container according to a matching criterion.
 
template<class Operation >
requires Aleph::PredicateWith<Operation &, const T &>
Aleph::DynList< T > filter (Operation &&operation) const
 Overload of filter() that accepts rvalues.
 
template<class Operation >
requires Aleph::PredicateWith<Operation &, const T &>
Aleph::DynList< const T * > ptr_filter (Operation &operation) const
 Filter the elements of a container according to a matching criterion and return a pointer to the matched items in the container.
 
template<class Operation >
requires Aleph::PredicateWith<Operation &, const T &>
Aleph::DynList< const T * > ptr_filter (Operation &&operation) const
 Overload of ptr_filter() that accepts rvalues.
 
template<class Operation >
requires Aleph::PredicateWith<Operation &, const T &>
Aleph::DynList< std::tuple< T, size_t > > pfilter (Operation &operation) const
 Filter the elements of a container according to a matching criterion and determine its positions respect to the traversal of container.
 
template<class Operation >
requires Aleph::PredicateWith<Operation &, const T &>
Aleph::DynList< std::tuple< T, size_t > > pfilter (Operation &&operation) const
 Overload of pfilter() that accepts rvalues.
 
template<class Operation >
requires Aleph::PredicateWith<Operation &, const T &>
std::pair< Aleph::DynList< T >, Aleph::DynList< T > > partition (Operation &op) const
 Exclusive partition of container according to a filter criterion.
 
template<class Operation >
requires Aleph::PredicateWith<Operation &, const T &>
std::pair< Aleph::DynList< T >, Aleph::DynList< T > > partition (Operation &&op) const
 Overload of partition() that accepts rvalues.
 
std::pair< Aleph::DynList< T >, Aleph::DynList< T > > partition (size_t n) const
 Exclusive partition of container in the nth item.
 
std::pair< Aleph::DynList< T >, Aleph::DynList< T > > split_half () const
 Split the container into two halves by alternating elements.
 
template<class Operation >
requires Aleph::PredicateWith<Operation &, const T &>
std::tuple< Aleph::DynList< T >, Aleph::DynList< T > > tpartition (Operation &op) const
 Exclusive partition of container according to a filter criterion.
 
template<class Operation >
requires Aleph::PredicateWith<Operation &, const T &>
std::tuple< Aleph::DynList< T >, Aleph::DynList< T > > tpartition (Operation &&op) const
 Overload of tpartition() that accepts rvalues.
 
size_t length () const noexcept
 Count the number of elements of a container.
 
Aleph::DynList< T > rev () const
 Return a list with the elements of container in reverse order respect to its traversal order.
 
Aleph::DynList< T > take (const size_t n) const
 Return a list with the first n elements seen in the container during its traversal.
 
Aleph::DynList< T > take (size_t i, const size_t j, const size_t step=1) const
 Return a list with elements seen in the container between i and j position respect to its traversal.
 
Aleph::DynList< T > drop (const size_t n) const
 Drop the first n elements seen in the container during its traversal.
 
void mutable_drop (const size_t n)
 Drop the first n elements seen from container.
 
- Public Member Functions inherited from GenericItems< Container, T >
Aleph::DynList< T > items () const
 Return a list of all the elements of a container sorted by traversal order.
 
Aleph::DynList< T > keys () const
 
- Public Member Functions inherited from EqualToMethod< Container >
bool equal_to (const Container &r) const noexcept
 Test if elements of this are exactly contained in another container.
 
bool operator== (const Container &r) const noexcept
 
bool operator!= (const Container &r) const noexcept
 Negation of equal_to()
 
- Public Member Functions inherited from StlAlephIterator< SetName >
iterator begin () noexcept
 Return an STL-compatible iterator to the first element.
 
iterator end () noexcept
 Return an STL-compatible end iterator.
 
const_iterator begin () const noexcept
 Return a const iterator to the first element.
 
const_iterator end () const noexcept
 Return a const end iterator.
 
const_iterator cbegin () const noexcept
 Return a const iterator to the first element.
 
const_iterator cend () const noexcept
 Return a const end iterator.
 

Static Private Member Functions

static size_t r_index (const size_t &i) noexcept
 

Private Attributes

DynArray< T > array
 
size_t num_items = 0
 
Compare cmp
 

Additional Inherited Members

- Public Attributes inherited from FunctionalMethods< Container, T >
template<typename __T = T, class Prop , class Operation >
requires (Aleph::DynList<__T> &l, Operation &op, const T &item)
 and { l.append(op(item))
 Conditional mapping of the elements of the container.
 

Detailed Description

template<typename T, class Compare = Aleph::less<T>>
requires StrictWeakOrder<Compare, T>
class Aleph::DynArrayHeap< T, Compare >

Dynamic heap (priority queue) backed by DynArray.

Template Parameters
Telement type stored in the heap
Comparecomparator defining the priority order
See also
BinHeap DynBinHeap ArrayHeap

Definition at line 148 of file tpl_dynArrayHeap.H.

Member Typedef Documentation

◆ Item_Type

template<typename T , class Compare = Aleph::less<T>>
using Aleph::DynArrayHeap< T, Compare >::Item_Type = T

Definition at line 165 of file tpl_dynArrayHeap.H.

Constructor & Destructor Documentation

◆ DynArrayHeap() [1/6]

template<typename T , class Compare = Aleph::less<T>>
Aleph::DynArrayHeap< T, Compare >::DynArrayHeap ( Compare  cmp_fct = Compare())
inline

Default constructor.

Definition at line 168 of file tpl_dynArrayHeap.H.

◆ DynArrayHeap() [2/6]

template<typename T , class Compare = Aleph::less<T>>
template<template< typename > class List>
Aleph::DynArrayHeap< T, Compare >::DynArrayHeap ( const List< T > &  l)
inline

Definition at line 173 of file tpl_dynArrayHeap.H.

◆ DynArrayHeap() [3/6]

template<typename T , class Compare = Aleph::less<T>>
template<class It >
Aleph::DynArrayHeap< T, Compare >::DynArrayHeap ( It  b,
It  e 
)
inline

Definition at line 173 of file tpl_dynArrayHeap.H.

◆ DynArrayHeap() [4/6]

template<typename T , class Compare = Aleph::less<T>>
Aleph::DynArrayHeap< T, Compare >::DynArrayHeap ( std::initializer_list< T >  l)
inline

Definition at line 173 of file tpl_dynArrayHeap.H.

◆ DynArrayHeap() [5/6]

template<typename T , class Compare = Aleph::less<T>>
template<typename ... Args>
Aleph::DynArrayHeap< T, Compare >::DynArrayHeap ( const T &  item,
Args &...  args 
)
inline

Definition at line 175 of file tpl_dynArrayHeap.H.

◆ DynArrayHeap() [6/6]

template<typename T , class Compare = Aleph::less<T>>
template<typename ... Args>
Aleph::DynArrayHeap< T, Compare >::DynArrayHeap ( T &&  item,
Args &...  args 
)
inline

Definition at line 175 of file tpl_dynArrayHeap.H.

Member Function Documentation

◆ append() [1/2]

template<typename T , class Compare = Aleph::less<T>>
T & Aleph::DynArrayHeap< T, Compare >::append ( const T &  key)
inline

Alias for insert().

Definition at line 262 of file tpl_dynArrayHeap.H.

References Aleph::DynArrayHeap< T, Compare >::insert().

Referenced by TEST().

◆ append() [2/2]

template<typename T , class Compare = Aleph::less<T>>
T & Aleph::DynArrayHeap< T, Compare >::append ( T &&  key)
inline

Alias for insert() (move overload).

Definition at line 265 of file tpl_dynArrayHeap.H.

References Aleph::DynArrayHeap< T, Compare >::insert().

◆ get()

template<typename T , class Compare = Aleph::less<T>>
T Aleph::DynArrayHeap< T, Compare >::get ( )
inline

Definition at line 295 of file tpl_dynArrayHeap.H.

References Aleph::DynArrayHeap< T, Compare >::getMin().

Referenced by TEST().

◆ getMax()

template<typename T , class Compare = Aleph::less<T>>
T Aleph::DynArrayHeap< T, Compare >::getMax ( )
inline

Definition at line 301 of file tpl_dynArrayHeap.H.

References Aleph::DynArrayHeap< T, Compare >::getMin().

Referenced by TEST().

◆ getMin()

template<typename T , class Compare = Aleph::less<T>>
Aleph::DynArrayHeap< T, Compare >::getMin ( )
inline

Remove and return the top element.

With the default comparator (Aleph::less<T>), this removes and returns the smallest element.

Exceptions
underflow_errorif the heap is empty.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 274 of file tpl_dynArrayHeap.H.

References ah_underflow_error_if, Aleph::DynArrayHeap< T, Compare >::array, Aleph::blossom_maximum_cardinality_matching(), Aleph::DynArrayHeap< T, Compare >::cmp, Aleph::DynArrayHeap< T, Compare >::num_items, and Aleph::sift_down().

Referenced by Aleph::DynArrayHeap< T, Compare >::get(), Aleph::DynArrayHeap< T, Compare >::getMax(), TEST(), TEST(), TEST(), and TEST().

◆ insert() [1/2]

template<typename T , class Compare = Aleph::less<T>>
T & Aleph::DynArrayHeap< T, Compare >::insert ( const T &  key)
inline

Insert a copy of key into the heap.

Parameters
[in]keyKey to insert.
Returns
A modifiable reference to the stored element.
Note
This reference points to an element inside the heap and can become invalid after further insertions/removals.

Definition at line 207 of file tpl_dynArrayHeap.H.

References Aleph::DynArrayHeap< T, Compare >::array, Aleph::DynArrayHeap< T, Compare >::cmp, Aleph::DynArrayHeap< T, Compare >::num_items, and Aleph::sift_up().

Referenced by Aleph::DynArrayHeap< T, Compare >::append(), Aleph::DynArrayHeap< T, Compare >::append(), Aleph::DynArrayHeap< T, Compare >::put(), Aleph::DynArrayHeap< T, Compare >::put(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().

◆ insert() [2/2]

template<typename T , class Compare = Aleph::less<T>>
T & Aleph::DynArrayHeap< T, Compare >::insert ( T &&  key)
inline

Insert a key by moving it into the heap.

Parameters
[in]keyKey to move.
Returns
A modifiable reference to the stored element.

Definition at line 219 of file tpl_dynArrayHeap.H.

References Aleph::DynArrayHeap< T, Compare >::array, Aleph::DynArrayHeap< T, Compare >::cmp, Aleph::DynArrayHeap< T, Compare >::num_items, and Aleph::sift_up().

◆ insert_direct() [1/2]

template<typename T , class Compare = Aleph::less<T>>
T & Aleph::DynArrayHeap< T, Compare >::insert_direct ( const T &  key)
inline

Insert by directly indexing into the backing array.

This variant uses operator() instead of touch().

Definition at line 240 of file tpl_dynArrayHeap.H.

References Aleph::DynArrayHeap< T, Compare >::array, Aleph::DynArrayHeap< T, Compare >::cmp, Aleph::DynArrayHeap< T, Compare >::num_items, and Aleph::sift_up().

Referenced by TEST().

◆ insert_direct() [2/2]

template<typename T , class Compare = Aleph::less<T>>
T & Aleph::DynArrayHeap< T, Compare >::insert_direct ( T &&  key)
inline

◆ is_empty()

template<typename T , class Compare = Aleph::less<T>>
constexpr bool Aleph::DynArrayHeap< T, Compare >::is_empty ( ) const
inlineconstexprnoexcept

Return true if the heap is empty.

Definition at line 310 of file tpl_dynArrayHeap.H.

References Aleph::DynArrayHeap< T, Compare >::num_items.

Referenced by TEST(), TEST(), and TEST().

◆ put() [1/2]

template<typename T , class Compare = Aleph::less<T>>
T & Aleph::DynArrayHeap< T, Compare >::put ( const T &  key)
inline

Alias for insert().

Definition at line 256 of file tpl_dynArrayHeap.H.

References Aleph::DynArrayHeap< T, Compare >::insert().

Referenced by TEST().

◆ put() [2/2]

template<typename T , class Compare = Aleph::less<T>>
T & Aleph::DynArrayHeap< T, Compare >::put ( T &&  key)
inline

Alias for insert() (move overload).

Definition at line 259 of file tpl_dynArrayHeap.H.

References Aleph::DynArrayHeap< T, Compare >::insert().

◆ r_index()

template<typename T , class Compare = Aleph::less<T>>
static size_t Aleph::DynArrayHeap< T, Compare >::r_index ( const size_t &  i)
inlinestaticprivatenoexcept

Definition at line 159 of file tpl_dynArrayHeap.H.

◆ reserve()

template<typename T , class Compare = Aleph::less<T>>
void Aleph::DynArrayHeap< T, Compare >::reserve ( size_t  n)
inline

Ensure the underlying array has capacity for at least n elements.

Exceptions
out_of_range_errorif n is smaller than the current size.

Definition at line 230 of file tpl_dynArrayHeap.H.

References ah_out_of_range_error_if, Aleph::DynArrayHeap< T, Compare >::array, and Aleph::DynArrayHeap< T, Compare >::num_items.

Referenced by TEST(), and TEST().

◆ size()

template<typename T , class Compare = Aleph::less<T>>
constexpr size_t Aleph::DynArrayHeap< T, Compare >::size ( ) const
inlineconstexprnoexcept

Return the number of elements.

Definition at line 307 of file tpl_dynArrayHeap.H.

References Aleph::DynArrayHeap< T, Compare >::num_items.

Referenced by TEST(), TEST(), and TEST().

◆ top() [1/2]

template<typename T , class Compare = Aleph::less<T>>
T & Aleph::DynArrayHeap< T, Compare >::top ( )
inline

Return the element with highest priority (the heap top).

With the default comparator (Aleph::less<T>), this is the smallest element.

Exceptions
underflow_errorif the heap is empty.

Definition at line 184 of file tpl_dynArrayHeap.H.

References ah_underflow_error_if, Aleph::DynArrayHeap< T, Compare >::array, and Aleph::DynArrayHeap< T, Compare >::num_items.

Referenced by TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().

◆ top() [2/2]

template<typename T , class Compare = Aleph::less<T>>
const T & Aleph::DynArrayHeap< T, Compare >::top ( ) const
inline

◆ traverse() [1/4]

template<typename T , class Compare = Aleph::less<T>>
template<class Operation >
bool Aleph::DynArrayHeap< T, Compare >::traverse ( Operation &&  operation = Operation())
inline

Definition at line 360 of file tpl_dynArrayHeap.H.

References Aleph::blossom_maximum_cardinality_matching().

◆ traverse() [2/4]

template<typename T , class Compare = Aleph::less<T>>
template<class Operation >
bool Aleph::DynArrayHeap< T, Compare >::traverse ( Operation &&  operation = Operation()) const
inline

Definition at line 354 of file tpl_dynArrayHeap.H.

References Aleph::blossom_maximum_cardinality_matching().

◆ traverse() [3/4]

template<typename T , class Compare = Aleph::less<T>>
template<class Operation >
bool Aleph::DynArrayHeap< T, Compare >::traverse ( Operation &  operation)
inline

Traverse all elements in the heap.

Iteration order is the internal heap array order (not sorted).

The traversal stops early if the operation returns false.

Definition at line 339 of file tpl_dynArrayHeap.H.

References Aleph::blossom_maximum_cardinality_matching(), and Aleph::DynArrayHeap< T, Compare >::Iterator::has_curr().

Referenced by TEST(), TEST(), and Aleph::DynArrayHeap< T, Compare >::traverse().

◆ traverse() [4/4]

template<typename T , class Compare = Aleph::less<T>>
template<class Operation >
bool Aleph::DynArrayHeap< T, Compare >::traverse ( Operation &  operation) const
inline

Member Data Documentation

◆ array

◆ cmp

◆ num_items


The documentation for this class was generated from the following file: