Template Class DaryHeap

Class Documentation

template<class T, class Better = std::less<T>, unsigned D = 4, bool BottomUp = false>
class DaryHeap

a D-ary heap of plain items, the best one by better() on top; pop() by the walk down from the top, or from the bottom up if BottomUp

Public Types

using Item = T

the type of the items

using value_type = T
using size_type = std::size_t
using difference_type = std::ptrdiff_t
using reference = const T&
using const_reference = const T&
using iterator = const T*
using const_iterator = const T*

Public Functions

explicit DaryHeap(Better better = Better())
void push(const T &x)

pushes x, moving it up while better than its parent

const T &top(void) const

the best item

Pre:

the heap is not empty

T pop(void)

removes the best item and returns it, the last item moved down from the root

Pre:

the heap is not empty

bool empty(void) const
std::size_t size(void) const
void reserve(std::size_t n)

room for n items, so that the pushes up to n do not reallocate

void clear(void)
inline const_iterator begin(void) const
inline const_iterator end(void) const
inline const_iterator cbegin(void) const
inline const_iterator cend(void) const