#include <soft_heap.hh>
Public Types | |
typedef T | element |
Element associated type. | |
Public Member Functions | |
void | clear () |
Clear the heap. | |
bool | is_empty () const |
Return true if there is at least one element. | |
bool | is_valid () const |
Return true if there is at least one element. | |
int | nelements () const |
Return the number of element in the heap. | |
T | pop_front () |
Returns the element with the lowest priority and remove it from the heap. | |
void | push (soft_heap< T, R > &sh) |
Merge sh with this heap. | |
void | push (const T &element) |
Add a new element element . | |
soft_heap (unsigned r=20) | |
Default constructor. | |
~soft_heap () | |
Destructor. |
T key, the data to store in the heap. For instance a point 2d. R rank, for instance int_u8
typedef T mln::util::soft_heap< T, R >::element |
Element associated type.
mln::util::soft_heap< T, R >::soft_heap | ( | unsigned | r = 20 |
) | [inline] |
Default constructor.
A corruption threshold r
can be specified. This threshold means that if nodes have a rank higher than this threshold they can be "corrupted" and therefore their rank can be reduced.
mln::util::soft_heap< T, R >::~soft_heap | ( | ) | [inline] |
void mln::util::soft_heap< T, R >::clear | ( | ) | [inline] |
Clear the heap.
References mln::util::head< T, R >::next(), mln::util::head< T, R >::queue(), mln::util::head< T, R >::set_next(), and mln::util::head< T, R >::set_prev().
bool mln::util::soft_heap< T, R >::is_empty | ( | ) | const [inline] |
Return true if there is at least one element.
bool mln::util::soft_heap< T, R >::is_valid | ( | ) | const [inline] |
Return true if there is at least one element.
Referenced by mln::util::soft_heap< T, R >::pop_front().
int mln::util::soft_heap< T, R >::nelements | ( | ) | const [inline] |
T mln::util::soft_heap< T, R >::pop_front | ( | ) | [inline] |
Returns the element with the lowest priority and remove it from the heap.
References mln::util::soft_heap< T, R >::is_valid(), mln::util::head< T, R >::next(), mln::util::node< T, R >::next(), mln::util::head< T, R >::prev(), mln::util::head< T, R >::queue(), and mln::util::head< T, R >::set_queue().
void mln::util::soft_heap< T, R >::push | ( | soft_heap< T, R > & | sh | ) | [inline] |
Merge sh
with this heap.
Be ware that after this call, sh
will be empty. This heap will hold the elements which were part of sh
.
References mln::util::soft_heap< T, R >::nelements(), mln::util::head< T, R >::next(), and mln::util::head< T, R >::queue().
void mln::util::soft_heap< T, R >::push | ( | const T & | element | ) | [inline] |
Add a new element element
.