Move Vector2i custom hash to separate header file.
This commit is contained in:
14
Core/include/Core/v2i_hash.hpp
Normal file
14
Core/include/Core/v2i_hash.hpp
Normal 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));
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user