Move Vector2i custom hash to separate header file.

This commit is contained in:
2025-03-19 15:44:44 -04:00
parent 23fb2892a9
commit 6b37c03079

View File

@@ -0,0 +1,14 @@
#pragma once
#include "J3ML/LinearAlgebra/Vector2i.hpp"
using namespace J3ML::LinearAlgebra;
template<>
struct std::hash<Vector2i>
{
std::size_t operator()(const Vector2i& k) const
{
// Read 2x int32_t into one int64_t and return std::hash<int64_t> to prevent collisions.
// This doesn't really gain any performance until you zoom out a lot.
return std::hash<int64_t>()(((int64_t) k.x << 32) | ((int64_t) k.y));
}
};