32 #ifndef LVR2_UTIL_MEAP_H_ 33 #define LVR2_UTIL_MEAP_H_ 37 #include <unordered_map> 39 #include <boost/optional.hpp> 43 using std::unordered_map;
56 template<
typename KeyT,
typename ValueT>
69 inline const KeyT&
key()
const {
77 inline const ValueT&
value()
const {
98 template<
typename KeyT,
typename ValueT>
111 Meap(
size_t capacity);
117 bool containsKey(KeyT
key)
const;
118 boost::optional<ValueT> insert(KeyT key,
const ValueT&
value);
119 boost::optional<ValueT> erase(KeyT key);
121 boost::optional<const ValueT&>
get(KeyT
key)
const;
122 size_t numValues()
const;
144 void updateValue(
const KeyT& key,
const ValueT& newValue);
149 bool isEmpty()
const;
153 std::vector<MeapPair<KeyT, ValueT>>
m_heap;
162 size_t father(
size_t child)
const;
168 size_t leftChild(
size_t father)
const;
174 size_t rightChild(
size_t father)
const;
182 void bubbleUp(
size_t idx);
187 void bubbleDown(
size_t idx);
190 void debugOutput()
const;
195 #include "lvr2/util/Meap.tcc"
std::vector< MeapPair< KeyT, ValueT > > m_heap
A map combined with a binary heap.
Element in a meap, consisting of a key and a value.
MeapPair(KeyT key, ValueT value)
unordered_map< KeyT, size_t > m_indices
Meap()
Initializes an empty meap.
const ValueT & value() const