MeVisLab Toolbox Reference
ml::WEMHeap< T > Class Template Reference

#include <WEMHeap.h>

Inheritance diagram for ml::WEMHeap< T >:
ml::WEMVector< WEMPrimitive >

Public Member Functions

 WEMHeap ()
 Standard constructor.
 WEMHeap (WEMHeap &&) noexcept=default
WEMHeapoperator= (WEMHeap &&) noexcept=default
 ~WEMHeap () override
 Standard destructor.
Troot ()
 Returns the root (first) element of this heap, typecast from WEMPrimitive to T.
const Troot () const
 Returns the root (first) element of this heap, typecast from WEMPrimitive to T.
void swap (unsigned int i, unsigned int j) override
 Swaps two heap elements given by their indices and resorts this heap.
void insert (WEMPrimitive *wp)
 Inserts the given heap element and resorts this heap.
void insert (WEMPrimitive *wp, double v)
 Inserts the given heap element and sets its value, and resorts this heap.
void update (WEMPrimitive *wp, double nv)
 Updates given heap element with the given value and resorts this heap.
int remove (WEMPrimitive *wp) override
 Removes the given heap element and resorts this heap.
void sort ()
 Sorts this heap.
void clear () override
 Remove all elements from heap.
Public Member Functions inherited from ml::WEMVector< WEMPrimitive >
 WEMVector (unsigned int init=0)
 Standard constructor.
WEMVectoroperator= (WEMVector &&other) noexcept
virtual ~WEMVector ()
 Standard destructor.
unsigned int num () const
 Returns the number of elements in this vector.
WEMPrimitiveat (unsigned int pos) const
 Returns the element at the given position or returns NULL if out of range.
WEMPrimitivefirst ()
 Returns the first element.
WEMPrimitivelast ()
 Returns the last element.
virtual unsigned int append (WEMPrimitive *elem)
 Appends the given element to back of this vector.
virtual void deleteAt (unsigned int pos)
 Deletes the element at the given position.
virtual void deleteLast ()
 Deletes the last element of this vector.
virtual int remove (WEMPrimitive *elem)
 Deletes the element given by its pointer.
virtual int lookup (WEMPrimitive *elem) const
 Searches for the given element in this vector and returns its position.
virtual int removeUnSwapped (WEMPrimitive *elem)
 Deletes the element given by its pointer. Keeps the order of the elements!
virtual void destroy ()
virtual void replace (WEMPrimitive *elem, unsigned int pos)
 Replaces the given position with the given element.
void reserve (unsigned int init)
 Reserves init elements, copies old ones if existing.

Additional Inherited Members

Protected Member Functions inherited from ml::WEMVector< WEMPrimitive >
virtual void expand ()
 Grow vector, add extra block of size BLOCKSIZE.
virtual unsigned int appendUnsafe (WEMPrimitive *elem)

Detailed Description

template<class T>
class ml::WEMHeap< T >

Min-Heap structure with property v[i]<v[2*i+1] and v[i]<v[2*i+2] Parent at index i has children at indices 2*i+1 and 2*i+2 Smallest values are stored closer to root of tree. Elements are sorted while inserting them in the heap.

Definition at line 28 of file WEMHeap.h.

Constructor & Destructor Documentation

◆ WEMHeap() [1/2]

template<class T>
ml::WEMHeap< T >::WEMHeap ( )

Standard constructor.

Definition at line 75 of file WEMHeap.h.

References WEMHeap(), and ml::WEMVector< WEMPrimitive >::WEMVector().

Referenced by operator=(), WEMHeap(), and WEMHeap().

◆ WEMHeap() [2/2]

template<class T>
ml::WEMHeap< T >::WEMHeap ( WEMHeap< T > && )
defaultnoexcept

References WEMHeap().

◆ ~WEMHeap()

template<class T>
ml::WEMHeap< T >::~WEMHeap ( )
override

Standard destructor.

Definition at line 82 of file WEMHeap.h.

References clear().

Member Function Documentation

◆ clear()

template<class T>
void ml::WEMHeap< T >::clear ( )
overridevirtual

Remove all elements from heap.

Reimplemented from ml::WEMVector< WEMPrimitive >.

Definition at line 278 of file WEMHeap.h.

References ml::WEMVector< WEMPrimitive >::at(), ml::WEMVector< T, fixedBufferSize >::clear(), and ml::WEMVector< WEMPrimitive >::num().

Referenced by operator=(), sort(), and ~WEMHeap().

◆ insert() [1/2]

template<class T>
void ml::WEMHeap< T >::insert ( WEMPrimitive * wp)

Inserts the given heap element and resorts this heap.

Definition at line 124 of file WEMHeap.h.

References ml::WEMVector< T, fixedBufferSize >::appendUnsafe(), ml::WEMPrimitive::getHeapPosition(), ml::WEMVector< WEMPrimitive >::last(), and ml::WEMVector< WEMPrimitive >::num().

Referenced by operator=(), and sort().

◆ insert() [2/2]

template<class T>
void ml::WEMHeap< T >::insert ( WEMPrimitive * wp,
double v )

◆ operator=()

template<class T>
WEMHeap & ml::WEMHeap< T >::operator= ( WEMHeap< T > && )
defaultnoexcept

◆ remove()

template<class T>
int ml::WEMHeap< T >::remove ( WEMPrimitive * wp)
override

◆ root() [1/2]

template<class T>
T * ml::WEMHeap< T >::root ( )

Returns the root (first) element of this heap, typecast from WEMPrimitive to T.

Definition at line 90 of file WEMHeap.h.

References ml::WEMVector< T, fixedBufferSize >::first(), and T.

Referenced by operator=(), and root().

◆ root() [2/2]

template<class T>
const T * ml::WEMHeap< T >::root ( ) const

Returns the root (first) element of this heap, typecast from WEMPrimitive to T.

Definition at line 106 of file WEMHeap.h.

References root(), and T.

◆ sort()

◆ swap()

template<class T>
void ml::WEMHeap< T >::swap ( unsigned int i,
unsigned int j )
overridevirtual

Swaps two heap elements given by their indices and resorts this heap.

Reimplemented from ml::WEMVector< WEMPrimitive >.

Definition at line 114 of file WEMHeap.h.

References ml::WEMVector< WEMPrimitive >::at(), and ml::WEMVector< T, fixedBufferSize >::swap().

Referenced by operator=(), and remove().

◆ update()

template<class T>
void ml::WEMHeap< T >::update ( WEMPrimitive * wp,
double nv )

Updates given heap element with the given value and resorts this heap.

Definition at line 194 of file WEMHeap.h.

References ml::WEMPrimitive::getHeapPosition(), ml::WEMPrimitive::getHeapValue(), ml::WEMVector< WEMPrimitive >::num(), and ml::WEMPrimitive::setHeapValue().

Referenced by insert(), and operator=().


The documentation for this class was generated from the following file:
  • MeVisLab/Standard/Sources/ML/MLWEM/WEMDataStructure/WEMHeap.h