Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::BinHeap< Key, Compare > Struct Template Reference

Node heap without virtual destructor. More...

#include <tpl_binHeap.H>

Inheritance diagram for Aleph::BinHeap< Key, Compare >:
[legend]
Collaboration diagram for Aleph::BinHeap< Key, Compare >:
[legend]

Public Types

using Node = BinHeapNode< Key >
 The heap's node type.
 
- Public Types inherited from Aleph::GenBinHeap< NodeType, Key, Compare >
using Node = NodeType< Key >
 

Additional Inherited Members

- Public Member Functions inherited from Aleph::GenBinHeap< NodeType, Key, Compare >
Compare & key_comp () noexcept
 
Compare & get_compare () noexcept
 
void swap (GenBinHeap &h) noexcept
 
Node * getRoot () noexcept
 
Node * getRoot () const noexcept
 
template<class Operation >
bool preorder_traverse (Operation op) const
 
template<class Operation >
void for_each_in_preorder (Operation &operation) const
 
template<class Operation >
void for_each_in_preorder (Operation &&operation=Operation()) const
 
template<class Operation >
void for_each_in_inorder (Operation &operation) const
 
template<class Operation >
void for_each_in_inorder (Operation &&operation=Operation()) const
 
template<class Op >
bool level_traverse (Op operation=Op()) const
 
 GenBinHeap () noexcept(std::is_nothrow_default_constructible_v< Node > and std::is_nothrow_default_constructible_v< Compare > and std::is_nothrow_constructible_v< Compare, Compare & >)
 Builds an empty heap with a comparison built by default.
 
 GenBinHeap (Compare __cmp) noexcept(std::is_nothrow_default_constructible_v< Node > and std::is_nothrow_constructible_v< Compare, Compare & >)
 Builds an empty heap with the comparison __cmp.
 
virtual ~GenBinHeap () noexcept
 
Node * insert (Node *p) noexcept(nothrow_cmp)
 Inserts a node into a heap.
 
Node * getMin_ne () noexcept(nothrow_cmp)
 Removes the node with the lowest priority from a heap that is not empty.
 
Node * getMin ()
 Removes the node with the lowest priority from the heap.
 
Node * getMax ()
 See getMin(); to use when the priority order is reversed.
 
void update (Node *p) noexcept(nothrow_cmp)
 Updates the priority of a node contained in the heap.
 
Node * remove (Node *node)
 Removes node from the heap.
 
void remove_all_and_delete () noexcept
 Deletes all the nodes of the heap, invokes the destructors of the removed nodes, and frees all the memory.
 
Node * top ()
 Returns the node with the lowest priority according to the comparison criterion specified in the declaration.
 
Node * top () const
 
const size_t & size () const noexcept
 
bool is_empty () const noexcept
 
bool verify_heap () const
 Checks the order of the heap.
 
- Protected Member Functions inherited from Aleph::GenBinHeap< NodeType, Key, Compare >
virtual bool verify_heap (Node *p) const
 Whether no node of the tree of root p has a key less than that of its parent.
 
- Static Protected Member Functions inherited from Aleph::GenBinHeap< NodeType, Key, Compare >
static Node * advance_left (Node *p) noexcept
 The left child of p, or null if it has none.
 
static Node * advance_right (Node *p) noexcept
 The right child of p, or null if it has none.
 
- Protected Attributes inherited from Aleph::GenBinHeap< NodeType, Key, Compare >
Compare cmp
 
- Static Protected Attributes inherited from Aleph::GenBinHeap< NodeType, Key, Compare >
static constexpr bool nothrow_cmp
 

Detailed Description

template<class Key, typename Compare = Aleph::less<Key>>
requires StrictWeakOrder<Compare, Key>
struct Aleph::BinHeap< Key, Compare >

Node heap without virtual destructor.

The BinHeap class implements a heap of nodes. It is not on an array, but on a binary tree of linked nodes, which makes it highly dynamic: the memory used is proportional to the number of nodes of the heap. The description of the file tpl_binHeap.H, in its section "Representation", tells how the tree is kept.

Parameters
Keythe key that each node keeps.
Comparethe criterion of comparison between the keys of the Nodes; by default is the relationship "less than".
See also
BinHeapVtl DynBinHeap

Definition at line 1411 of file tpl_binHeap.H.

Member Typedef Documentation

◆ Node

template<class Key , typename Compare = Aleph::less<Key>>
using Aleph::BinHeap< Key, Compare >::Node = BinHeapNode<Key>

The heap's node type.

Definition at line 1414 of file tpl_binHeap.H.


The documentation for this struct was generated from the following file: