Template Class BinaryHeap
Defined in File BinaryHeap.h
Nested Relationships
Nested Types
Class Documentation
-
template<typename _T, class LessThan = std::less<_T>>
class BinaryHeap This class provides an implementation of an updatable min-heap. Using it is a bit cumbersome, as it requires keeping track of the BinaryHeap::Element* type, however, it should be as fast as it gets with an updatable heap.
Public Types
Public Functions
-
inline BinaryHeap()
-
inline ~BinaryHeap()
-
inline void onAfterInsert(EventAfterInsert event, void *arg)
Set the event that gets called after insertion.
-
inline void onBeforeRemove(EventBeforeRemove event, void *arg)
Set the event that gets called before a removal.
-
inline void clear()
Clear the heap.
-
inline void pop()
Remove the top element.
-
inline void buildFrom(const std::vector<_T> &list)
Clear the heap, add the set of elements list to it and rebuild it.
-
inline void rebuild()
Rebuild the heap.
-
inline bool empty() const
Check if the heap is empty.
-
inline unsigned int size() const
Get the number of elements in the heap.
-
class Element
When an element is added to the heap, an instance of Element* is created. This instance contains the data that was added and internal information about the position of the data in the heap’s internal storage.
-
inline BinaryHeap()