Skip to content

Instantly share code, notes, and snippets.

@andrewc12
Created December 2, 2024 03:59
Show Gist options
  • Select an option

  • Save andrewc12/73d33bf694b5eeb2af38e3a59f77e2e7 to your computer and use it in GitHub Desktop.

Select an option

Save andrewc12/73d33bf694b5eeb2af38e3a59f77e2e7 to your computer and use it in GitHub Desktop.
namespace std
{
// Needed to use ESM::FormId as a key in std::unordered_map
template <>
struct hash<ESM::FormId>
{
size_t operator()(const ESM::FormId& formId) const
{
// Hash each member and combine them
size_t h1 = std::hash<uint32_t>()(formId.mIndex);
size_t h2 = std::hash<int32_t>()(formId.mContentFile);
// Combine the hashes of mIndex and mContentFile
return h1 ^ (h2 << 1); // XOR with shift to create a combined hash
}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment