implement peek_index() functions for all binary heap storage classes

This commit is contained in:
Dennis Luxen 2015-01-15 11:15:48 +01:00
parent 527e6cbc72
commit 6dabf4507a

View File

@ -50,6 +50,11 @@ template <typename NodeID, typename Key> class ArrayStorage
Key &operator[](NodeID node) { return positions[node]; } Key &operator[](NodeID node) { return positions[node]; }
Key peek_index(const NodeID node) const
{
return positions[node];
}
void Clear() {} void Clear() {}
private: private:
@ -65,6 +70,15 @@ template <typename NodeID, typename Key> class MapStorage
void Clear() { nodes.clear(); } void Clear() { nodes.clear(); }
Key peek_index(const NodeID node) const
{
const auto iter = nodes.find(node);
if (std::end(nodes) != iter)
{
return iter->second;
}
return Key(-1);
}
private: private:
std::map<NodeID, Key> nodes; std::map<NodeID, Key> nodes;
}; };