Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::dynarrayheap_detail Namespace Reference

Classes

struct  Way
 The places that an item passes, in order, when it is sifted. More...
 

Functions

template<typename T , class Compare >
size_t up_index (DynArray< T > &a, const size_t l, const size_t r, T &x, Compare &cmp, Way< T > &way) noexcept(Aleph::NothrowPredicateWith< Compare &, T &, T & >)
 Find where an item that enters at the end of a heap goes.
 
template<typename T , class Compare >
size_t down_index (DynArray< T > &a, const size_t l, const size_t r, T &x, Compare &cmp, Way< T > &way) noexcept(Aleph::NothrowPredicateWith< Compare &, T &, T & >)
 Find where an item that enters at the root of a heap goes.
 
template<typename T >
void shift (T &first, const Way< T > &way, T &x)
 Move an item along its way.
 

Function Documentation

◆ down_index()

template<typename T , class Compare >
size_t Aleph::dynarrayheap_detail::down_index ( DynArray< T > &  a,
const size_t  l,
const size_t  r,
T &  x,
Compare &  cmp,
Way< T > &  way 
)
inlinenoexcept

Find where an item that enters at the root of a heap goes.

The comparisons of sift_down(), which move nothing and do not read the entry l.

Parameters
[in]athe array of the heap.
[in]lthe index where x enters, the root of the heap [l, r].
[in]rthe last index of the heap.
[in]xthe item that enters; not constant, as in up_index().
[in]cmpthe comparison.
[out]waythe children that x passes, in order.
Returns
the index where x goes.
Exceptions
whatthe comparison throws; nothing when it is noexcept.

Definition at line 137 of file tpl_dynArrayHeap.H.

References cmp(), l, Aleph::l_index(), and r.

Referenced by Aleph::DynArrayHeap< T, Compare >::getMin(), and Aleph::sift_down().

◆ shift()

template<typename T >
void Aleph::dynarrayheap_detail::shift ( T &  first,
const Way< T > &  way,
T &  x 
)
inline

Move an item along its way.

Each item of the way takes the place of the one before it, the first one that of first, and x takes the last place.

Parameters
[in,out]firstthe place where x enters.
[in]waythe places that x passes, from up_index() or down_index().
[in,out]xthe item, left moved from. It must not be first nor a place of the way, which lose their items before x is moved.

Definition at line 184 of file tpl_dynArrayHeap.H.

References Aleph::dynarrayheap_detail::Way< T >::at, k, and Aleph::dynarrayheap_detail::Way< T >::len.

Referenced by Aleph::DynArrayHeap< T, Compare >::enter(), Aleph::DynArrayHeap< T, Compare >::getMin(), Aleph::DynArrayHeap< T, Compare >::insert(), Aleph::DynArrayHeap< T, Compare >::insert_direct(), Aleph::sift_down(), and Aleph::sift_up().

◆ up_index()

template<typename T , class Compare >
size_t Aleph::dynarrayheap_detail::up_index ( DynArray< T > &  a,
const size_t  l,
const size_t  r,
T &  x,
Compare &  cmp,
Way< T > &  way 
)
inlinenoexcept

Find where an item that enters at the end of a heap goes.

The comparisons of sift_up(), which move nothing.

Parameters
[in]athe array of the heap.
[in]lthe first index of the heap.
[in]rthe index where x enters, after the heap [l, r - 1].
[in]xthe item that enters. It is not constant, as the items of the array are not: the comparison takes both in the same way, the one that the noexcept specification looks at.
[in]cmpthe comparison.
[out]waythe parents that x passes, in order.
Returns
the index where x goes.
Exceptions
whatthe comparison throws; nothing when it is noexcept.

Definition at line 99 of file tpl_dynArrayHeap.H.

References cmp(), l, r, and Aleph::u_index().

Referenced by Aleph::DynArrayHeap< T, Compare >::enter(), Aleph::DynArrayHeap< T, Compare >::insert(), Aleph::DynArrayHeap< T, Compare >::insert_direct(), and Aleph::sift_up().