Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
tpl_dynArrayHeap.H File Reference

Array-based dynamic binary heap. More...

#include <ah-concepts.H>
#include <algorithm>
#include <climits>
#include <cstddef>
#include <memory>
#include <stdexcept>
#include <type_traits>
#include <utility>
#include <tpl_dynArray.H>
#include <ah-errors.H>
#include <ah-iterator.H>
Include dependency graph for tpl_dynArrayHeap.H:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  Aleph::dynarrayheap_detail::Way< T >
 The places that an item passes, in order, when it is sifted. More...
 
class  Aleph::DynArrayHeap< T, Compare >
 Dynamic heap (priority queue) backed by DynArray. More...
 
class  Aleph::DynArrayHeap< T, Compare >::Iterator
 Iterator on the items of the heap, in the order of its array, which is not the sorted one. More...
 

Namespaces

namespace  Aleph
 Main namespace for Aleph-w library functions.
 
namespace  Aleph::dynarrayheap_detail
 

Functions

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) 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 Aleph::dynarrayheap_detail::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 Aleph::dynarrayheap_detail::shift (T &first, const Way< T > &way, T &x)
 Move an item along its way.
 
template<typename T , class Compare >
size_t Aleph::sift_up (DynArray< T > &a, const size_t l, const size_t r, Compare &cmp) noexcept(Aleph::NothrowPredicateWith< Compare &, T &, T & >)
 Restore heap order by moving an element up.
 
template<typename T , class Compare >
void Aleph::sift_down (DynArray< T > &a, const size_t l, const size_t r, Compare &cmp) noexcept(Aleph::NothrowPredicateWith< Compare &, T &, T & >)
 Restore heap order by moving an element down.
 

Detailed Description

Array-based dynamic binary heap.

Binary heap using DynArray for automatic growth. Efficient for priority queues with unknown size.

Features

  • O(log n) insert, extract-min
  • Automatic resizing
  • Cache-friendly array storage
Note
Due to the underlying DynArray directory, segment, and block structuring, not all entries in the heap are contiguous in memory. Only the entries within the same block are contiguous.
See also
tpl_binHeap.H Fixed-size array heap
tpl_dynBinHeap.H Node-based heap
Author
Leandro Rabindranath León

Definition in file tpl_dynArrayHeap.H.