Open
Description
In case you have a hash collision when computing the hash of the pair of points, you will overwrite existing entries. Instead of using the hash as a key, you should use the actual pair, and use an associated hash function, ie:
struct PointHash
{
size_t operator()(Point3D a) const
{
return std::hash<double>{}(a.x) ^ std::hash<double>{}(a.y) ^ std::hash<double>{}(a.z);
}
};
struct EdgeEndpoints
{
Point3D p1;
Point3D p2;
constexpr bool operator==(const EdgeEndpoints&) const = default;
constexpr bool operator!=(const EdgeEndpoints&) const = default;
};
struct EdgeEndpointHash
{
size_t operator()(EdgeEndpoints const& a) const
{
return PointHash{}(a.p1) ^ PointHash{}(a.p2);
}
};
std::unordered_map<EdgeEndpoints, Edge*, EdgeEndpointHash> map_edges;
Also, please do not convert to string when computing hashes.
Metadata
Metadata
Assignees
Labels
No labels