50# ifndef TPL_DYNBINHEAP_H
51# define TPL_DYNBINHEAP_H
73 template <
class T,
class Compare = Aleph::less<T>>
181 return insert(std::forward<T>(item));
219 Node * node = Node::key_to_node(data);
269 template <
class Operation>
273 {
return op(p->get_key()); });
276 template <
class Operation>
282 template <
class Operation>
286 {
return op(p->get_key()); });
289 template <
class Operation>
304 return KEY(Base::Iterator::get_curr_ne());
Variadic constructor macros for containers.
#define Args_Ctor(Name, Type)
Container traversal and functional operation mixins.
DRY (Don't Repeat Yourself) utilities and macros.
#define Special_Ctors(Set_Type, Type)
Generates special constructors for containers.
static BinHeapNode * key_to_node(Key &__key) noexcept
Dynamic heap of elements of type T ordered by a comparison functor.
T & top() const
Return a reference to the smallest element.
T get()
Alias for getMin().
DynBinHeap(const DynBinHeap &h)
bool traverse(Operation &&op=Operation())
bool erase(T &data) noexcept
Alias for remove().
DynBinHeap(Compare &cmp) noexcept
bool traverse(Operation &&op=Operation()) const
bool traverse(Operation &op) const
T getMin()
Remove the minimum element (according to Compare) and return it.
void copy(const DynBinHeap &src)
void update(T &data) noexcept
Adjust the position of an element after mutating its priority.
void empty() noexcept
Remove every element.
bool remove(T &data) noexcept
Remove an arbitrary element belonging to the heap.
T & put(const T &item)
Synonym of insert().
T & __insert(Node *p) noexcept
typename BinHeap< T, Compare >::Node Node
DynBinHeap(DynBinHeap &&h)
BinHeap< T, Compare > Base
bool traverse(Operation &op)
DynBinHeap & operator=(const DynBinHeap &h)
T & insert(const T &item)
Insert a copy of item into the heap.
DynBinHeap(Compare &&cmp=Compare()) noexcept
T & append(const T &item)
bool preorder_traverse(Node *p, Operation op) const
void update(Node *p) noexcept
Actualiza prioridad de un nodo contenido en el heap.
bool is_empty() const noexcept
Node * getMin()
Elimina del heap el nodo de menor prioridad.
Node * remove(Node *node)
Elimina del heap el nodo node.
void remove_all_and_delete() noexcept
Borra todos los nodos del heap, invoca a los destructores de los nodos eliminados y libera toda la me...
void for_each_in_preorder(Operation &operation) const
Node * insert(Node *p) noexcept
Inserta un nodo en un heap.
Node * top()
Retorna el nodo con menor prioridad según el criterio de comparación especificado en la declaración.
Equality test for containers.
Common methods to the Aleph-w ( ) containers.
Aleph::DynList< __T > maps(Operation &op) const
Map the elements of the container.
Common sequential searching methods on containers.
Mixin that adds STL begin()/end() and cbegin()/cend() to Aleph containers.
Singly linked list implementations with head-tail access.
Main namespace for Aleph-w library functions.
T & swap(T &t1, T &t2)
Generic swap using object's swap method.
std::decay_t< typename HeadC::Item_Type > T
Node heap without virtual destructor.
const T & get_curr_ne() const noexcept
const T & get_curr() const
Iterator() noexcept=default
Default constructor creates an "end" iterator.
Generic list of items stored in a container.
Binary heap implementation using tree structure.
Utility functions for binary tree operations.