|
Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
|
Fixed-capacity binary heap backed by a raw array. More...
#include <tpl_arrayHeap.H>
Classes | |
| struct | Iterator |
Public Types | |
| using | Item_Type = T |
| using | Key_Type = T |
| using | Const_Iterator = Aleph::Const_Iterator< Iterator > |
| Read-only iterator: the iterator of a constant container. | |
Public Types inherited from StlAlephIterator< SetName > | |
| using | iterator = StlIterator< SetName > |
| using | const_iterator = StlConstIterator< SetName > |
Public Member Functions | |
| void | allocate_storage (const size_t new_dim) |
| Allocate internal storage and reset the heap. | |
| void | swap (ArrayHeap &h) noexcept |
| Swap all state with another heap. | |
| template<template< typename > class List> | |
| ArrayHeap (const List< T > &l) | |
| template<class It > requires (not std::is_arithmetic_v<It> and requires (It it) { *it; ++it; it != it; }) | |
| ArrayHeap (It b, It e) | |
| ArrayHeap (std::initializer_list< T > l) | |
| ArrayHeap (const size_t d=1024, Compare cmp_fct=Compare()) | |
| Construct an empty heap with internal storage. | |
| ArrayHeap (T *ptr, const size_t &d, Compare cmp_fct=Compare()) | |
| Construct an empty heap using an external buffer. | |
| ArrayHeap (const ArrayHeap &h) | |
| ArrayHeap (ArrayHeap &&h) noexcept | |
| ArrayHeap & | operator= (const ArrayHeap &h) |
| ArrayHeap & | operator= (ArrayHeap &&h) noexcept |
| virtual | ~ArrayHeap () |
| Destructor. | |
| T & | top () |
| Return a mutable reference to the minimum element. | |
| const T & | top () const |
| Return a const reference to the minimum element. | |
| T & | insert_ne (const T &key) |
| Insert an element without checking capacity. | |
| T & | insert_ne (T &&key) |
| Insert an element without checking capacity (move overload). | |
| T & | insert (const T &key) |
| Insert an element into the heap. | |
| T & | insert (T &&key) |
| Insert an element into the heap (move overload). | |
| T & | put (const T &key) |
| Synonym for insert(). | |
| T & | append (const T &key) |
| Synonym for insert(). | |
| T & | put (T &&key) |
| Synonym for insert() (move overload). | |
| T & | append (T &&key) |
| Synonym for insert() (move overload). | |
| T | getMin () |
| Remove the smallest element in the heap and return a copy of its value. | |
| T | get () |
See getMin(). | |
| T | getMax () |
See getMin(). | |
| constexpr size_t | size () const noexcept |
| Return the number of elements currently stored. | |
| constexpr bool | is_empty () const noexcept |
| Return true if the heap is empty. | |
| constexpr size_t | capacity () const noexcept |
| Return the maximum number of elements that can be stored. | |
| void | update (T &data) |
| Update the priority of an element stored in the heap. | |
| void | remove (T &item) |
| Remove an element from the heap given a reference to it. | |
| T & | operator[] (const size_t i) |
| Return a mutable reference to the i-th entry (1-based). | |
| const T & | operator[] (const size_t i) const |
| Const overload of operator[] (1-based). | |
| template<class Operation > requires Aleph::PredicateWith<Operation &, const T &> | |
| bool | traverse (Operation &operation) const noexcept(Aleph::NothrowPredicateWith< Operation &, const T & >) |
| Traverse all elements (const overload). | |
| template<class Operation > requires Aleph::PredicateWith<Operation &, T &> | |
| bool | traverse (Operation &operation) noexcept(Aleph::NothrowPredicateWith< Operation &, T & >) |
| Traverse all elements. | |
| template<class Operation > requires Aleph::PredicateWith<Operation &, const T &> | |
| bool | traverse (Operation &&operation=Operation()) const noexcept(Aleph::NothrowPredicateWith< Operation &, const T & >) |
| Traverse all elements (const forwarding overload). | |
| template<class Operation > requires Aleph::PredicateWith<Operation &, T &> | |
| bool | traverse (Operation &&operation=Operation()) noexcept(Aleph::NothrowPredicateWith< Operation &, T & >) |
| Traverse all elements (forwarding overload). | |
Public Member Functions inherited from LocateFunctions< Container, Type > | |
| auto | get_it () |
| Return a properly initialized iterator positioned at the first item on the container. | |
| auto | get_it () const |
| Read-only iterator positioned at the first item. | |
| auto | get_it (const size_t pos) |
Return a properly initialized iterator positioned at the pos item on the container. | |
| auto | get_it (const size_t pos) const |
Read-only iterator positioned at the pos item. | |
| auto | get_itor () |
Alias of get_it(). | |
| auto | get_itor () const |
See get_itor(). | |
| template<class C = Container> requires Aleph::dry_detail::MutablyTraversable<C, Type> | |
| Type & | nth_ne (const size_t n) noexcept(Aleph::dry_detail::mutable_traversal_is_noexcept< C, Type >) |
| Return the n‑th element without bounds checking. | |
| const Type & | nth_ne (const size_t n) const noexcept(Aleph::dry_detail::const_traversal_is_noexcept< Container, Type >) |
Constant overload of nth_ne(size_t). | |
| template<class C = Container> requires Aleph::dry_detail::MutablyTraversable<C, Type> | |
| 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::InvocablePredicateWith<Operation &, Type &> | |
| and Aleph::dry_detail::MutablyTraversable< typename Aleph::concepts_detail::defer< Container, Operation >::type, Type > Type * | find_ptr (Operation &operation) noexcept(mutable_search_is_noexcept< Operation >()) |
| Find a pointer to an item in the container according to a searching criterion. | |
| template<class Operation > requires Aleph::InvocablePredicateWith<Operation &, const Type &> | |
| const Type * | find_ptr (Operation &operation) const noexcept(const_search_is_noexcept< Operation >()) |
Const overload of find_ptr(Operation&). | |
| template<class Operation > requires Aleph::InvocablePredicateWith<Operation &, const Type &> | |
| const Type * | find_ptr (Operation &&operation) const noexcept(const_search_is_noexcept< Operation >()) |
| Overload of find_ptr() const that accepts rvalues. | |
| template<class Operation > requires Aleph::InvocablePredicateWith<Operation &, Type &> | |
| and Aleph::dry_detail::MutablyTraversable< typename Aleph::concepts_detail::defer< Container, Operation >::type, Type > Type * | find_ptr (Operation &&operation) noexcept(mutable_search_is_noexcept< Operation >()) |
| Overload of find_ptr() that accepts rvalues. | |
| template<class Operation > requires Aleph::InvocablePredicateWith<Operation &, const Type &> | |
| size_t | find_index (Operation &operation) const noexcept(const_search_is_noexcept< Operation >()) |
| Find the position of an item in the container according to a searching criterion. | |
| template<class Operation > requires Aleph::InvocablePredicateWith<Operation &, const Type &> | |
| size_t | find_index (Operation &&operation) const noexcept(const_search_is_noexcept< Operation >()) |
| Overload of find_index() that accepts rvalues. | |
| template<class Operation , class T = Type> requires Aleph::InvocablePredicateWith<Operation &, const Type &> | |
| and std::default_initializable< T > and std::copy_constructible< T > std::tuple< bool, Type > | find_item (Operation &operation) const noexcept(find_item_is_noexcept< Operation >()) |
| Safe sequential searching of an item matching a criterion. | |
| template<class Operation , class T = Type> requires Aleph::InvocablePredicateWith<Operation &, const Type &> | |
| and std::default_initializable< T > and std::copy_constructible< T > std::tuple< bool, Type > | find_item (Operation &&operation) const noexcept(find_item_is_noexcept< Operation >()) |
| Overload of find_item() that accepts rvalues. | |
| template<class Operation , class T = Type> requires Aleph::InvocablePredicateWith<Operation &, const Type &> | |
| and std::copy_constructible< T > std::optional< Type > | find_opt (Operation &operation) const |
| Copy of the first item satisfying a criterion, if any. | |
| template<class Operation , class T = Type> requires Aleph::InvocablePredicateWith<Operation &, const Type &> | |
| and std::copy_constructible< T > std::optional< Type > | find_opt (Operation &&operation) const |
| Overload of find_opt() that accepts rvalues. | |
| template<class Operation > requires Aleph::InvocablePredicateWith<Operation &, const Type &> | |
| bool | contains_if (Operation &&operation) const noexcept(const_search_is_noexcept< Operation >()) |
| Test if an item satisfying a criterion is present in the container. | |
| template<class T = Type> requires requires(const T & a, const T & b) { { a == b } -> std::convertible_to<bool>; } | |
| 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 > | |
| void | emplace (Args &&... args) |
| Appends a new element into the container by constructing it from the given args. | |
| void | emplace_end (Args &&... args) |
See emplace(Args && ... args). | |
| void | emplace_ins (Args &&... args) |
| template<typename... Args> requires ((std::convertible_to<Args &&, T> and ...) and (Aleph::InsertableWith<typename Aleph::concepts_detail::defer<Container, std::tuple<Args...>>::type, Item_Arg<Args>> and ...)) | |
| size_t | ninsert (Args &&... args) |
| Insert n variadic items. | |
| template<typename... Args> requires ((std::convertible_to<Args &&, T> and ...) and (Aleph::AppendableWith<typename Aleph::concepts_detail::defer<Container, std::tuple<Args...>>::type, Item_Arg<Args>> and ...)) | |
| size_t | nappend (Args &&... args) |
| Append n variadic items. | |
| template<class Operation > requires Aleph::InvocableWith<Operation &, const T &> | |
| void | for_each (Operation &operation) const |
| Traverse all the container and performs an operation on each element. | |
| template<class Operation > requires Aleph::InvocableWith<Operation &, const T &> | |
| void | for_each (Operation &&operation) const |
| Overload of for_each() that accepts rvalues. | |
| template<class Operation > requires Aleph::InvocableWith<Operation &, const T &> | |
| void | each (Operation &operation) const |
| Alias of for_each(). | |
| template<class Operation > requires Aleph::InvocableWith<Operation &, const T &> | |
| void | each (Operation &&operation) const |
| Alias of for_each() that accepts rvalues. | |
| template<class Operation > requires Aleph::InvocableWith<Operation &, const T &> | |
| void | each (const size_t pos, const size_t slice, Operation &operation) const |
Traverse the container starting at pos taking one item every slice, performing an operation on each visited element. | |
| template<class Operation > requires Aleph::InvocableWith<Operation &, const T &> | |
| void | each (const size_t pos, const size_t slice, Operation &&operation) const |
See each(size_t pos, size_t slice, Operation & operation) const. | |
| template<class Operation > requires Aleph::InvocableWith<Operation &, T &> | |
| and Aleph::dry_detail::MutablyTraversable< typename Aleph::concepts_detail::defer< Container, Operation >::type, T > void | each (const size_t pos, const size_t slice, Operation &operation) |
Traverse the container starting at pos taking one item every slice, performing an operation that may modify each visited item. | |
| template<class Operation > requires Aleph::InvocableWith<Operation &, T &> | |
| and Aleph::dry_detail::MutablyTraversable< typename Aleph::concepts_detail::defer< Container, Operation >::type, T > void | each (const size_t pos, const size_t slice, Operation &&operation) |
See each(size_t pos, size_t slice, Operation & operation). | |
| template<class Operation > requires Aleph::InvocableWith<Operation &, T &> | |
| and Aleph::dry_detail::MutablyTraversable< typename Aleph::concepts_detail::defer< Container, Operation >::type, T > void | mutable_for_each (Operation &operation) |
| Apply a mutable operation to each element of the container. | |
| template<class Operation > requires Aleph::InvocableWith<Operation &, T &> | |
| and Aleph::dry_detail::MutablyTraversable< typename Aleph::concepts_detail::defer< Container, Operation >::type, T > void | mutable_for_each (Operation &&operation) |
See mutable_for_each(Operation & operation). | |
| template<class Operation > requires Aleph::InvocablePredicateWith<Operation &, const T &> | |
| bool | all (Operation &operation) const |
| Check if all the elements of the container satisfy a condition. | |
| template<class Operation > requires Aleph::InvocablePredicateWith<Operation &, const T &> | |
| bool | all (Operation &&operation) const |
| Overload of all() that accepts rvalues. | |
| template<class Operation > requires Aleph::InvocablePredicateWith<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::InvocablePredicateWith<Operation &, const T &> | |
| bool | exists (Operation &&op) const |
| Overload of exists() that accepts rvalues. | |
| template<class Operation > requires Aleph::InvocablePredicateWith<Operation &, const T &> | |
| bool | none (Operation &op) const |
| Test that no element satisfies a criterion. | |
| template<class Operation > requires Aleph::InvocablePredicateWith<Operation &, const T &> | |
| bool | none (Operation &&op) const |
| Overload of none() that accepts rvalues. | |
| template<class Operation > requires Aleph::InvocablePredicateWith<Operation &, const T &> | |
| size_t | count_if (Operation &op) const |
| Count the elements that satisfy a criterion. | |
| template<class Operation > requires Aleph::InvocablePredicateWith<Operation &, const T &> | |
| size_t | count_if (Operation &&op) const |
| Overload of count_if() that accepts rvalues. | |
| Aleph::DynList< Aleph::dry_detail::map_result_t< R, Operation &, T > > | maps (Operation &op) const |
| Aleph::DynList< Aleph::dry_detail::map_result_t< R, Operation &, T > > | maps (Operation &&op) const |
| Aleph::DynList< Aleph::dry_detail::map_result_t< R, Operation &, T > > | maps_if (Prop prop, Operation &op) const |
| Aleph::DynList< Aleph::dry_detail::map_result_t< R, Operation &, T > > | maps_if (Prop prop, Operation &&op) const |
| Aleph::DynList< Aleph::dry_detail::map_result_t< R, Operation &, T > > | map (Operation &op) const |
| Aleph::DynList< Aleph::dry_detail::map_result_t< R, Operation &, T > > | map (Operation &&op) const |
| Aleph::DynList< Aleph::dry_detail::map_result_t< R, Operation &, T > > | map_if (Prop prop, Operation &op) const |
| Aleph::DynList< Aleph::dry_detail::map_result_t< R, Operation &, T > > | map_if (Prop prop, Operation &&op) const |
| template<class Operation > requires Aleph::InvocableWith<Operation &, const T &> | |
| auto | flat_map (Operation &op) const |
| Map each element to a container and concatenate the results. | |
| template<class Operation > requires Aleph::InvocableWith<Operation &, const T &> | |
| auto | flat_map (Operation &&op) const |
| Overload of flat_map() that accepts rvalues. | |
| Aleph::DynList< T > | to_dynlist () const |
| Convert container to DynList. | |
| std::vector< T > | to_vector () const |
| Convert container to std::vector. | |
| template<typename Acc = T, class Op > requires Aleph::dry_detail::FoldOperation<Op, Acc, T> | |
| Acc | foldl (const Acc &init, Op &op) const |
| Fold the elements of the container to a specific result. | |
| template<typename Acc = T, class Op > requires Aleph::dry_detail::FoldOperation<Op, Acc, T> | |
| Acc | foldl (const Acc &init, Op &&op) const |
| Overload of foldl() that accepts rvalues. | |
| template<typename Acc = T, class Op > requires Aleph::dry_detail::FoldOperation<Op, Acc, T> | |
| Acc | fold_left (const Acc &init, Op &op) const |
| Alias for foldl(). | |
| template<typename Acc = T, class Op > requires Aleph::dry_detail::FoldOperation<Op, Acc, T> | |
| Acc | fold_left (const Acc &init, Op &&op) const |
| Overload of fold_left() that accepts rvalues. | |
| template<class Operation > requires Aleph::dry_detail::FoldOperation<Operation, T, T> | |
| 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 Aleph::dry_detail::FoldOperation<Operation, T, T> | |
| T | fold (const T &init, Operation &&operation) const |
| Overload of fold() that accepts rvalues. | |
| template<typename Acc = T, class Op > requires Aleph::dry_detail::FoldRightOperation<Op, Acc, T> | |
| Acc | foldr (const Acc &init, Op &op) const |
| Fold the elements from the last to the first. | |
| template<typename Acc = T, class Op > requires Aleph::dry_detail::FoldRightOperation<Op, Acc, T> | |
| Acc | foldr (const Acc &init, Op &&op) const |
| Overload of foldr() that accepts rvalues. | |
| template<class Op , class U = T> requires Aleph::dry_detail::FoldOperation<Op, T, T> | |
| and std::copy_constructible< U > std::optional< T > | reduce (Op &op) const |
| Fold the elements with no initial value. | |
| template<class Op , class U = T> requires Aleph::dry_detail::FoldOperation<Op, T, T> | |
| and std::copy_constructible< U > std::optional< T > | reduce (Op &&op) const |
| Overload of reduce() that accepts rvalues. | |
| template<class Operation > requires Aleph::InvocablePredicateWith<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::InvocablePredicateWith<Operation &, const T &> | |
| Aleph::DynList< T > | filter (Operation &&operation) const |
| Overload of filter() that accepts rvalues. | |
| template<class Operation > requires Aleph::InvocablePredicateWith<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::InvocablePredicateWith<Operation &, const T &> | |
| Aleph::DynList< const T * > | ptr_filter (Operation &&operation) const |
| Overload of ptr_filter() that accepts rvalues. | |
| template<class Operation > requires Aleph::InvocablePredicateWith<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::InvocablePredicateWith<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::InvocablePredicateWith<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::InvocablePredicateWith<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::InvocablePredicateWith<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::InvocablePredicateWith<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(Aleph::dry_detail::const_traversal_is_noexcept< Container, T >) |
| 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 the elements at positions i, i + step, i + 2 step, ... that are not greater than j, respect to the traversal order. | |
| Aleph::DynList< T > | drop (const size_t n) const |
| Drop the first n elements seen in the container during its traversal. | |
| template<class Operation > requires Aleph::InvocablePredicateWith<Operation &, const T &> | |
| Aleph::DynList< T > | take_while (Operation &op) const |
| The longest prefix of elements that satisfy a criterion. | |
| template<class Operation > requires Aleph::InvocablePredicateWith<Operation &, const T &> | |
| Aleph::DynList< T > | take_while (Operation &&op) const |
| Overload of take_while() that accepts rvalues. | |
| template<class Operation > requires Aleph::InvocablePredicateWith<Operation &, const T &> | |
| Aleph::DynList< T > | drop_while (Operation &op) const |
| The elements after the longest prefix that satisfies a criterion. | |
| template<class Operation > requires Aleph::InvocablePredicateWith<Operation &, const T &> | |
| Aleph::DynList< T > | drop_while (Operation &&op) const |
| Overload of drop_while() that accepts rvalues. | |
| template<class C = Container> requires requires (C & c) { c.remove(); } | |
| 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 |
See items(). | |
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. | |
Private Member Functions | |
| template<class Operation > | |
| bool | traverse_impl (Operation &operation) |
| template<class Operation > | |
| bool | const_traverse_impl (Operation &operation) const |
Static Private Member Functions | |
| static size_t | r_index (const size_t &i) |
Private Attributes | |
| T * | array = nullptr |
| size_t | dim = 0 |
| size_t | num_items = 0 |
| bool | array_allocated = false |
| Compare | cmp |
Static Private Attributes | |
| static constexpr bool | nothrow_cmp |
Additional Inherited Members | |
Static Public Member Functions inherited from FunctionalMethods< Container, T > | |
| template<typename... Items> requires ((std::convertible_to<Items &&, T> and ...) and (Aleph::AppendableWith<typename Aleph::concepts_detail::defer<Container, std::tuple<Items...>>::type, Item_Arg<Items>> and ...)) | |
| static Container | build (Items &&... items) |
| Build a container that holds the given items. | |
| template<class D , typename... Items> requires (std::derived_from<D, typename Aleph::concepts_detail::defer<Container, D>::type> and std::default_initializable<D> and (std::convertible_to<Items &&, T> and ...) and (Aleph::AppendableWith<typename Aleph::concepts_detail::defer<Container, std::tuple<D, Items...>>::type, Item_Arg<Items>> and ...)) | |
| static D | build_as (Items &&... items) |
Build a D, a class derived from the container, holding the given items. | |
Public Attributes inherited from FunctionalMethods< Container, T > | |
| template<typename... Args> requires (typename Aleph::concepts_detail::defer<Container, std::tuple<Args...>>::type & c, T && x) | |
| and { c.append(std::move(x)) | |
| Insert a new element into the container by constructing it from the given args. | |
| template<typename R = void, class Prop , class Operation > requires (Aleph::DynList<Aleph::dry_detail::map_result_t<R, Operation &, T>> & l, Operation & op, const T & item) | |
| and Aleph::InvocableWith< Operation &, const T & > | and { l.append(std::invoke(op, item)) |
| Conditional mapping of the elements of the container. | |
Fixed-capacity binary heap backed by a raw array.
The heap stores elements from index 1 to num_items and keeps index 0 as sentinel, which simplifies the parent/child arithmetic.
| T | element type |
| Compare | comparator defining the priority order |
Definition at line 441 of file tpl_arrayHeap.H.
| using Aleph::ArrayHeap< T, Compare >::Const_Iterator = Aleph::Const_Iterator<Iterator> |
Read-only iterator: the iterator of a constant container.
Definition at line 925 of file tpl_arrayHeap.H.
| using Aleph::ArrayHeap< T, Compare >::Item_Type = T |
Definition at line 510 of file tpl_arrayHeap.H.
| using Aleph::ArrayHeap< T, Compare >::Key_Type = T |
Definition at line 512 of file tpl_arrayHeap.H.
|
inline |
Definition at line 514 of file tpl_arrayHeap.H.
|
inline |
Definition at line 514 of file tpl_arrayHeap.H.
|
inline |
Definition at line 514 of file tpl_arrayHeap.H.
|
inline |
Construct an empty heap with internal storage.
| [in] | d | capacity (number of usable heap slots) |
| [in] | cmp_fct | comparator |
| invalid_argument | if d == 0 |
| overflow_error | if the array of d + 1 entries, with the entry 0 that a heap does not use, does not fit in a size_t |
| bad_alloc | if there is no memory for the array |
Definition at line 525 of file tpl_arrayHeap.H.
References Aleph::ArrayHeap< T, Compare >::allocate_storage().
|
inline |
Construct an empty heap using an external buffer.
The heap will not manage the lifetime of ptr.
| [in] | ptr | external buffer (must have at least d + 1 elements) |
| [in] | d | capacity (number of usable heap slots) |
| [in] | cmp_fct | comparator |
| invalid_argument | if ptr == nullptr or d == 0 |
Definition at line 540 of file tpl_arrayHeap.H.
References ah_invalid_argument_if.
|
inline |
Definition at line 546 of file tpl_arrayHeap.H.
References Aleph::ArrayHeap< T, Compare >::allocate_storage(), Aleph::ArrayHeap< T, Compare >::array, h, and Aleph::ArrayHeap< T, Compare >::num_items.
|
inlinenoexcept |
Definition at line 555 of file tpl_arrayHeap.H.
References h, and Aleph::ArrayHeap< T, Compare >::swap().
|
inlinevirtual |
Destructor.
Definition at line 585 of file tpl_arrayHeap.H.
References FunctionalMethods< Container, T >::and, Aleph::ArrayHeap< T, Compare >::array, and Aleph::ArrayHeap< T, Compare >::array_allocated.
|
inline |
Allocate internal storage and reset the heap.
| [in] | new_dim | new capacity (number of usable heap slots) |
| invalid_argument | if new_dim == 0 |
| overflow_error | if the array of new_dim + 1 entries, with the entry 0 that a heap does not use, does not fit in a size_t. Then the heap is as it was. |
| bad_alloc | if there is no memory for the array; the heap is then as it was. |
Definition at line 478 of file tpl_arrayHeap.H.
References ah_invalid_argument_if, ah_overflow_error_if, Aleph::ArrayHeap< T, Compare >::array, Aleph::ArrayHeap< T, Compare >::array_allocated, Aleph::ArrayHeap< T, Compare >::dim, and Aleph::ArrayHeap< T, Compare >::num_items.
Referenced by Aleph::ArrayHeap< T, Compare >::ArrayHeap(), Aleph::ArrayHeap< T, Compare >::ArrayHeap(), and Aleph::ArrayHeap< T, Compare >::operator=().
|
inline |
Synonym for insert().
| [in] | key | value to insert |
Definition at line 708 of file tpl_arrayHeap.H.
References Aleph::ArrayHeap< T, Compare >::insert().
|
inline |
Synonym for insert() (move overload).
| [in] | key | value to insert |
Definition at line 724 of file tpl_arrayHeap.H.
References Aleph::ArrayHeap< T, Compare >::insert().
|
inlineconstexprnoexcept |
Return the maximum number of elements that can be stored.
This excludes the sentinel slot at index 0.
Definition at line 787 of file tpl_arrayHeap.H.
References Aleph::ArrayHeap< T, Compare >::dim.
|
inlineprivate |
Definition at line 941 of file tpl_arrayHeap.H.
References Aleph::ArrayHeap< T, Compare >::array, and Aleph::ArrayHeap< T, Compare >::num_items.
Referenced by Aleph::ArrayHeap< T, Compare >::traverse(), and Aleph::ArrayHeap< T, Compare >::traverse().
|
inline |
See getMin().
Definition at line 766 of file tpl_arrayHeap.H.
References Aleph::ArrayHeap< T, Compare >::getMin().
Referenced by TEST().
|
inline |
See getMin().
Definition at line 772 of file tpl_arrayHeap.H.
References Aleph::ArrayHeap< T, Compare >::getMin().
Referenced by TEST().
|
inline |
Remove the smallest element in the heap and return a copy of its value.
getMin() extracts the element with the lowest value according to the configured comparator.
| underflow_error | if the heap is empty. |
| what | the comparison throws, with the heap as it was if the move of the items and the exchange of two of them do not throw. |
Definition at line 737 of file tpl_arrayHeap.H.
References ah_underflow_error_if, Aleph::ArrayHeap< T, Compare >::array, Aleph::ArrayHeap< T, Compare >::cmp, Aleph::ArrayHeap< T, Compare >::num_items, and Aleph::sift_down().
Referenced by Aleph::ArrayHeap< T, Compare >::get(), Aleph::ArrayHeap< T, Compare >::getMax(), main(), TEST(), TEST(), TEST(), and TEST().
|
inline |
Insert an element into the heap.
insert(key) stores a copy of key inside the heap.
| [in] | key | value to insert. |
| overflow_error | if the internal array is full. |
Definition at line 675 of file tpl_arrayHeap.H.
References ah_overflow_error_if, Aleph::ArrayHeap< T, Compare >::dim, Aleph::ArrayHeap< T, Compare >::insert_ne(), and Aleph::ArrayHeap< T, Compare >::num_items.
Referenced by Aleph::ArrayHeap< T, Compare >::append(), Aleph::ArrayHeap< T, Compare >::append(), main(), Aleph::ArrayHeap< T, Compare >::put(), Aleph::ArrayHeap< T, Compare >::put(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().
|
inline |
Insert an element into the heap (move overload).
| [in] | key | value to insert |
| overflow_error | if the internal array is full |
Definition at line 688 of file tpl_arrayHeap.H.
References ah_overflow_error_if, Aleph::ArrayHeap< T, Compare >::dim, Aleph::ArrayHeap< T, Compare >::insert_ne(), and Aleph::ArrayHeap< T, Compare >::num_items.
|
inline |
Insert an element without checking capacity.
| [in] | key | value to insert |
| what | the comparison or the copy of key throw, with the heap as it was if the exchange of two items does not throw. |
Definition at line 622 of file tpl_arrayHeap.H.
References Aleph::ArrayHeap< T, Compare >::array, Aleph::ArrayHeap< T, Compare >::cmp, Aleph::ArrayHeap< T, Compare >::num_items, r, and Aleph::sift_up().
Referenced by Aleph::ArrayHeap< T, Compare >::insert(), Aleph::ArrayHeap< T, Compare >::insert(), and TEST().
|
inline |
Insert an element without checking capacity (move overload).
| [in] | key | value to insert |
| what | the comparison throws, with the heap as it was if the exchange of two items does not throw, and key too, which takes its item back by a move assignment. If that assignment throws too, what it throws goes out instead, and the item of key is lost. |
key may be an item of this heap. The move, which comes before the comparisons, changes that item where it is, and the heap does not put that item in order again. Definition at line 649 of file tpl_arrayHeap.H.
References Aleph::ArrayHeap< T, Compare >::array, Aleph::ArrayHeap< T, Compare >::cmp, Aleph::ArrayHeap< T, Compare >::num_items, r, and Aleph::sift_up().
|
inlineconstexprnoexcept |
Return true if the heap is empty.
Definition at line 781 of file tpl_arrayHeap.H.
References Aleph::ArrayHeap< T, Compare >::num_items.
|
inlinenoexcept |
Definition at line 577 of file tpl_arrayHeap.H.
References h, and Aleph::ArrayHeap< T, Compare >::swap().
|
inline |
Definition at line 561 of file tpl_arrayHeap.H.
References Aleph::ArrayHeap< T, Compare >::allocate_storage(), Aleph::ArrayHeap< T, Compare >::array, Aleph::ArrayHeap< T, Compare >::cmp, Aleph::ArrayHeap< T, Compare >::dim, h, and Aleph::ArrayHeap< T, Compare >::num_items.
|
inline |
Return a mutable reference to the i-th entry (1-based).
No bounds checking is performed.
| [in] | i | index |
i Definition at line 892 of file tpl_arrayHeap.H.
References Aleph::ArrayHeap< T, Compare >::array.
|
inline |
Const overload of operator[] (1-based).
| [in] | i | index |
i Definition at line 902 of file tpl_arrayHeap.H.
References Aleph::ArrayHeap< T, Compare >::array.
|
inline |
Synonym for insert().
| [in] | key | value to insert |
Definition at line 700 of file tpl_arrayHeap.H.
References Aleph::ArrayHeap< T, Compare >::insert().
|
inline |
Synonym for insert() (move overload).
| [in] | key | value to insert |
Definition at line 716 of file tpl_arrayHeap.H.
References Aleph::ArrayHeap< T, Compare >::insert().
|
inlinestaticprivate |
Definition at line 462 of file tpl_arrayHeap.H.
|
inline |
Remove an element from the heap given a reference to it.
The reference must refer to an element stored in this heap.
| [in,out] | item | reference to the element to remove |
| underflow_error | if the heap is empty |
| what | the comparison throws, with the heap as it was if the exchange of two items does not throw. |
item is a valid reference into this heap. Definition at line 834 of file tpl_arrayHeap.H.
References ah_underflow_error_if, FunctionalMethods< Container, T >::and, Aleph::ArrayHeap< T, Compare >::array, Aleph::ArrayHeap< T, Compare >::cmp, Aleph::ArrayHeap< T, Compare >::nothrow_cmp, Aleph::ArrayHeap< T, Compare >::num_items, and Aleph::sift_down_up().
Referenced by TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().
|
inlineconstexprnoexcept |
Return the number of elements currently stored.
Definition at line 778 of file tpl_arrayHeap.H.
References Aleph::ArrayHeap< T, Compare >::num_items.
Referenced by exists_in_heap(), main(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().
|
inlinenoexcept |
Swap all state with another heap.
| [in,out] | h | other heap |
Definition at line 501 of file tpl_arrayHeap.H.
References Aleph::ArrayHeap< T, Compare >::array, Aleph::ArrayHeap< T, Compare >::array_allocated, Aleph::ArrayHeap< T, Compare >::cmp, Aleph::ArrayHeap< T, Compare >::dim, h, and Aleph::ArrayHeap< T, Compare >::num_items.
Referenced by Aleph::ArrayHeap< T, Compare >::ArrayHeap(), and Aleph::ArrayHeap< T, Compare >::operator=().
|
inline |
Return a mutable reference to the minimum element.
| underflow_error | if the heap is empty |
Definition at line 595 of file tpl_arrayHeap.H.
References ah_underflow_error_if, Aleph::ArrayHeap< T, Compare >::array, and Aleph::ArrayHeap< T, Compare >::num_items.
|
inline |
Return a const reference to the minimum element.
| underflow_error | if the heap is empty |
Definition at line 606 of file tpl_arrayHeap.H.
References ah_underflow_error_if, Aleph::ArrayHeap< T, Compare >::array, and Aleph::ArrayHeap< T, Compare >::num_items.
|
inlinenoexcept |
Traverse all elements (const forwarding overload).
| Operation | callable type |
| [in] | operation | functor to apply |
Definition at line 990 of file tpl_arrayHeap.H.
References Aleph::ArrayHeap< T, Compare >::const_traverse_impl().
|
inlinenoexcept |
Traverse all elements (forwarding overload).
| Operation | callable type |
| [in] | operation | functor to apply |
Definition at line 1004 of file tpl_arrayHeap.H.
References Aleph::ArrayHeap< T, Compare >::traverse_impl().
|
inlinenoexcept |
Traverse all elements (const overload).
Iterates over indices [1, size()] and applies operation to each element until it returns false.
| Operation | callable type |
| [in,out] | operation | functor to apply |
Definition at line 962 of file tpl_arrayHeap.H.
References Aleph::ArrayHeap< T, Compare >::const_traverse_impl().
Referenced by TEST().
|
inlinenoexcept |
Traverse all elements.
| Operation | callable type |
| [in,out] | operation | functor to apply |
Definition at line 976 of file tpl_arrayHeap.H.
References Aleph::ArrayHeap< T, Compare >::traverse_impl().
|
inlineprivate |
Definition at line 930 of file tpl_arrayHeap.H.
References Aleph::ArrayHeap< T, Compare >::array, and Aleph::ArrayHeap< T, Compare >::num_items.
Referenced by Aleph::ArrayHeap< T, Compare >::traverse(), and Aleph::ArrayHeap< T, Compare >::traverse().
|
inline |
Update the priority of an element stored in the heap.
update(data) takes a reference to an element inside the heap, presumably modified, and updates its priority inside the heap.
The reference must have been obtained via a previous call to insert().
| [in] | data | reference to the element inside the heap to update |
| what | the comparison throws. Then no item has moved, if the exchange of two items does not throw: the heap is as it was before the call, with data at its place, where its new priority may be out of order. |
data is a valid reference into this heap. Results are unpredictable (and probably fatal) if this is not the case. Definition at line 806 of file tpl_arrayHeap.H.
References ah_underflow_error_if, FunctionalMethods< Container, T >::and, Aleph::ArrayHeap< T, Compare >::array, Aleph::ArrayHeap< T, Compare >::cmp, Aleph::ArrayHeap< T, Compare >::num_items, and Aleph::sift_down_up().
Referenced by TEST().
|
private |
Definition at line 446 of file tpl_arrayHeap.H.
Referenced by Aleph::ArrayHeap< T, Compare >::ArrayHeap(), Aleph::ArrayHeap< T, Compare >::~ArrayHeap(), Aleph::ArrayHeap< T, Compare >::allocate_storage(), Aleph::ArrayHeap< T, Compare >::const_traverse_impl(), Aleph::ArrayHeap< T, Compare >::getMin(), Aleph::ArrayHeap< T, Compare >::insert_ne(), Aleph::ArrayHeap< T, Compare >::insert_ne(), Aleph::ArrayHeap< T, Compare >::operator=(), Aleph::ArrayHeap< T, Compare >::operator[](), Aleph::ArrayHeap< T, Compare >::operator[](), Aleph::ArrayHeap< T, Compare >::remove(), Aleph::ArrayHeap< T, Compare >::swap(), Aleph::ArrayHeap< T, Compare >::top(), Aleph::ArrayHeap< T, Compare >::top(), Aleph::ArrayHeap< T, Compare >::traverse_impl(), and Aleph::ArrayHeap< T, Compare >::update().
|
mutableprivate |
Definition at line 450 of file tpl_arrayHeap.H.
Referenced by Aleph::ArrayHeap< T, Compare >::~ArrayHeap(), Aleph::ArrayHeap< T, Compare >::allocate_storage(), and Aleph::ArrayHeap< T, Compare >::swap().
|
private |
Definition at line 452 of file tpl_arrayHeap.H.
Referenced by Aleph::ArrayHeap< T, Compare >::getMin(), Aleph::ArrayHeap< T, Compare >::insert_ne(), Aleph::ArrayHeap< T, Compare >::insert_ne(), Aleph::ArrayHeap< T, Compare >::operator=(), Aleph::ArrayHeap< T, Compare >::remove(), Aleph::ArrayHeap< T, Compare >::swap(), and Aleph::ArrayHeap< T, Compare >::update().
|
mutableprivate |
Definition at line 447 of file tpl_arrayHeap.H.
Referenced by Aleph::ArrayHeap< T, Compare >::allocate_storage(), Aleph::ArrayHeap< T, Compare >::capacity(), Aleph::ArrayHeap< T, Compare >::insert(), Aleph::ArrayHeap< T, Compare >::insert(), Aleph::ArrayHeap< T, Compare >::operator=(), and Aleph::ArrayHeap< T, Compare >::swap().
|
staticconstexprprivate |
Definition at line 458 of file tpl_arrayHeap.H.
Referenced by Aleph::ArrayHeap< T, Compare >::remove().
|
private |
Definition at line 448 of file tpl_arrayHeap.H.
Referenced by Aleph::ArrayHeap< T, Compare >::ArrayHeap(), Aleph::ArrayHeap< T, Compare >::allocate_storage(), Aleph::ArrayHeap< T, Compare >::const_traverse_impl(), Aleph::ArrayHeap< T, Compare >::getMin(), Aleph::ArrayHeap< T, Compare >::insert(), Aleph::ArrayHeap< T, Compare >::insert(), Aleph::ArrayHeap< T, Compare >::insert_ne(), Aleph::ArrayHeap< T, Compare >::insert_ne(), Aleph::ArrayHeap< T, Compare >::is_empty(), Aleph::ArrayHeap< T, Compare >::operator=(), Aleph::ArrayHeap< T, Compare >::remove(), Aleph::ArrayHeap< T, Compare >::size(), Aleph::ArrayHeap< T, Compare >::swap(), Aleph::ArrayHeap< T, Compare >::top(), Aleph::ArrayHeap< T, Compare >::top(), Aleph::ArrayHeap< T, Compare >::traverse_impl(), and Aleph::ArrayHeap< T, Compare >::update().