Add geom::simplex hash

This commit is contained in:
Nikita Lisitsa 2023-02-28 01:35:25 +03:00
parent 8b456ce9e9
commit ac436cb155

View file

@ -1,6 +1,7 @@
#pragma once
#include <psemek/geom/point.hpp>
#include <psemek/util/hash.hpp>
#include <iostream>
#include <type_traits>
@ -131,3 +132,21 @@ namespace psemek::geom
}
}
namespace std
{
template <typename Point, std::size_t K>
struct hash<::psemek::geom::simplex<Point, K>>
{
std::size_t operator()(::psemek::geom::simplex<Point, K> const & simplex) const
{
std::size_t result = 0;
std::hash<Point> h;
for (auto const & p : simplex.points)
::psemek::util::hash_combine(result, h(p));
return result;
}
};
}