MeshLib Documentation
Loading...
Searching...
No Matches
MR::Heap< T, I, P > Class Template Reference

stores map from element id in[0, size) to T; More...

#include <MRHeap.h>

Classes

struct  Element
 

Public Member Functions

 Heap (size_t size, T def={}, P pred={})
 constructs heap for given number of elements, assigning given default value to each element
 
 Heap (std::vector< Element > elms, P pred={})
 constructs heap from given elements (id's shall not repeat and have spaces, but can be arbitrary shuffled)
 
size_t size () const
 returns the size of the heap
 
void resize (size_t size, T def={})
 increases the size of the heap by adding elements at the end
 
const T & value (I elemId) const
 returns the value associated with given element
 
const Elementtop () const
 returns the element with the largest value
 
void setValue (I elemId, const T &newVal)
 sets new value to given element
 
void setLargerValue (I elemId, const T &newVal)
 sets new value to given element, which shall be larger/smaller than the current value
 
void setSmallerValue (I elemId, const T &newVal)
 
template<typename U >
void increaseValue (I elemId, const U &inc)
 
Element setTopValue (const T &newVal)
 sets new value to the current top element, returning its previous value
 

Detailed Description

template<typename T, typename I, typename P>
class MR::Heap< T, I, P >

stores map from element id in[0, size) to T;

provides two operations: 1) change the value of any element; 2) find the element with the largest value

Member Function Documentation

◆ increaseValue()

template<typename T , typename I , typename P >
template<typename U >
void MR::Heap< T, I, P >::increaseValue ( I elemId,
const U & inc )
inline

◆ setTopValue()

template<typename T , typename I , typename P >
Element MR::Heap< T, I, P >::setTopValue ( const T & newVal)
inline

sets new value to the current top element, returning its previous value

◆ size()

template<typename T , typename I , typename P >
size_t MR::Heap< T, I, P >::size ( ) const
inline

returns the size of the heap

◆ top()

template<typename T , typename I , typename P >
const Element & MR::Heap< T, I, P >::top ( ) const
inline

returns the element with the largest value

◆ value()

template<typename T , typename I , typename P >
const T & MR::Heap< T, I, P >::value ( I elemId) const
inline

returns the value associated with given element


The documentation for this class was generated from the following files: