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