Public Types | Public Member Functions

mln::util::soft_heap< T, R > Class Template Reference
[Utilities]

Soft heap. More...

#include <soft_heap.hh>

Inheritance diagram for mln::util::soft_heap< T, R >:
Inheritance graph

List of all members.

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.
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.

Detailed Description

template<typename T, typename R>
class mln::util::soft_heap< T, R >

Soft heap.

T key, the data to store in the heap. For instance a point 2d. R rank, for instance int_u8

Definition at line 178 of file soft_heap.hh.


Member Typedef Documentation

template<typename T, typename R>
typedef T mln::util::soft_heap< T, R >::element

Element associated type.

Definition at line 185 of file soft_heap.hh.


Constructor & Destructor Documentation

template<typename T , typename R >
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.

Definition at line 619 of file soft_heap.hh.

template<typename T , typename R >
mln::util::soft_heap< T, R >::~soft_heap (  )  [inline]

Destructor.

Definition at line 631 of file soft_heap.hh.


Member Function Documentation

template<typename T , typename R >
void mln::util::soft_heap< T, R >::clear (  )  [inline]

Clear the heap.

Definition at line 771 of file soft_heap.hh.

template<typename T , typename R >
bool mln::util::soft_heap< T, R >::is_empty (  )  const [inline]

Return true if there is at least one element.

Definition at line 753 of file soft_heap.hh.

template<typename T , typename R >
bool mln::util::soft_heap< T, R >::is_valid (  )  const [inline]

Return true if there is at least one element.

Definition at line 744 of file soft_heap.hh.

Referenced by mln::util::soft_heap< T, R >::pop_front().

template<typename T , typename R >
int mln::util::soft_heap< T, R >::nelements (  )  const [inline]

Return the number of element in the heap.

Definition at line 762 of file soft_heap.hh.

Referenced by mln::util::soft_heap< T, R >::push().

template<typename T , typename R >
T mln::util::soft_heap< T, R >::pop_front (  )  [inline]

Returns the element with the lowest priority and remove it from the heap.

Definition at line 675 of file soft_heap.hh.

References mln::util::soft_heap< T, R >::is_valid().

template<typename T , typename R >
void mln::util::soft_heap< T, R >::push ( const T &  element  )  [inline]

Add a new element element.

Definition at line 646 of file soft_heap.hh.

template<typename T , typename R >
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.

Definition at line 658 of file soft_heap.hh.

References mln::util::soft_heap< T, R >::nelements().