Skip to main content

GuidPairHash Struct

Hash functor for pairs of GUIDs. More...

Declaration

struct helios::engine::game::systems::physics::GridCollisionDetectionSystem::GuidPairHash { ... }

Public Operators Index

std::size_toperator() (const std::pair< helios::util::Guid, helios::util::Guid > &pair) const

Computes a hash value for a GUID pair. More...

Description

Hash functor for pairs of GUIDs.

Enables the use of GUID pairs as keys in unordered containers. The hash combines both GUIDs using XOR with a bit-shift to reduce collision probability for symmetric pairs.

Todo

switch to uint32_t once helios/#174 is implemented

Definition at line 93 of file GridCollisionDetectionSystem.ixx.

Public Operators

operator()()

std::size_t helios::engine::game::systems::physics::GridCollisionDetectionSystem::GuidPairHash::operator() (const std::pair< helios::util::Guid, helios::util::Guid > & pair)
inline

Computes a hash value for a GUID pair.

Parameters
pair

The pair of GUIDs to hash.

Returns

A combined hash value for both GUIDs.

Definition at line 102 of file GridCollisionDetectionSystem.ixx.

102 std::size_t operator()(const std::pair<helios::util::Guid, helios::util::Guid>& pair) const {
103
104 auto g1 = std::hash<helios::util::Guid>{}(pair.first);
105 auto g2 = std::hash<helios::util::Guid>{}(pair.second);
106
107 // compute the hash for the pair - shift g2 one position left, then xor with g1.
108 return g1 ^ (g2 << 1);
109 };

The documentation for this struct was generated from the following file:


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.