MeshLib C++ Docs
Loading...
Searching...
No Matches

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

#include <MRMesh/MRHeap.h>

Classes

struct  Element

Public Types

using SizeType = typename I::ValueType
 the type that can hold the number of elements of the maximal heap (e.g. int for FaceId and size_t for VoxelId)

Public Member Functions

 Heap (P pred={})
 constructs an empty heap
 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, but can have spaces and be arbitrary shuffled)
size_t size () const
 returns the size of the heap
void resize (size_t size, T def MR_LIFETIME_CAPTURE_BY_NESTED(this)={})
 increases the size of the heap by adding elements at the end
bool contains (I elemId) const
 returns true if given element is present in the heap
void push (I elemId, const T &val MR_LIFETIME_CAPTURE_BY_NESTED(this))
 adds given element, which is not present in the heap yet
void erase (I elemId)
 removes given element from the heap
void pop ()
 removes the element with the largest value from the heap
const T & value (I elemId) const
 returns the value associated with given element
const Element & top () const
 returns the element with the largest value
void setValue (I elemId, const T &newVal MR_LIFETIME_CAPTURE_BY_NESTED(this))
 sets new value to given element
void setLargerValue (I elemId, const T &newVal MR_LIFETIME_CAPTURE_BY_NESTED(this))
 sets new value to given element, which shall be larger/smaller than the current value
void setSmallerValue (I elemId, const T &newVal MR_LIFETIME_CAPTURE_BY_NESTED(this))
template<typename U>
void increaseValue (I elemId, const U &inc)
Element setTopValue (const T &newVal MR_LIFETIME_CAPTURE_BY_NESTED(this))
 sets new value to the current top element, returning its previous value

Detailed Description

template<typename T, typename I, typename P = std::less<T>>
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 Typedef Documentation

◆ SizeType

template<typename T, typename I, typename P = std::less<T>>
using MR::Heap< T, I, P >::SizeType = typename I::ValueType

the type that can hold the number of elements of the maximal heap (e.g. int for FaceId and size_t for VoxelId)

Constructor & Destructor Documentation

◆ Heap()

template<typename T, typename I, typename P = std::less<T>>
MR::Heap< T, I, P >::Heap ( P pred = {})
inline

constructs an empty heap

Member Function Documentation

◆ contains()

template<typename T, typename I, typename P = std::less<T>>
bool MR::Heap< T, I, P >::contains ( I elemId) const
inline

returns true if given element is present in the heap

◆ increaseValue()

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

◆ pop()

template<typename T, typename I, typename P = std::less<T>>
void MR::Heap< T, I, P >::pop ( )
inline

removes the element with the largest value from the heap

◆ setTopValue()

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

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

◆ size()

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

returns the size of the heap

◆ top()

template<typename T, typename I, typename P = std::less<T>>
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 = std::less<T>>
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 file: