Skip to main content

EntityHandlePairHash Struct

Hash functor for pairs of EntityHandles. More...

Declaration

struct helios::engine::modules::physics::collision::systems::GridCollisionDetectionSystem::EntityHandlePairHash { ... }

Public Operators Index

std::uint64_toperator() (const std::pair< helios::engine::ecs::EntityHandle, helios::engine::ecs::EntityHandle > &pair) const

Computes a hash value for an EntityHandle pair. More...

Description

Hash functor for pairs of EntityHandles.

Enables the use of EntityHandle pairs as keys in unordered containers. The hash combines both handles 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 120 of file GridCollisionDetectionSystem.ixx.

Public Operators

operator()()

std::uint64_t helios::engine::modules::physics::collision::systems::GridCollisionDetectionSystem::EntityHandlePairHash::operator() (const std::pair< helios::engine::ecs::EntityHandle, helios::engine::ecs::EntityHandle > & pair)
inline

Computes a hash value for an EntityHandle pair.

Parameters
pair

The pair of EntityHandles to hash.

Returns

A combined hash value for both handles.

Definition at line 129 of file GridCollisionDetectionSystem.ixx.

129 std::uint64_t operator()(const std::pair<helios::engine::ecs::EntityHandle, helios::engine::ecs::EntityHandle>& pair) const {
130
131 auto g1 = std::hash<helios::engine::ecs::EntityHandle>{}(pair.first);
132 auto g2 = std::hash<helios::engine::ecs::EntityHandle>{}(pair.second);
133
134 // compute the hash for the pair - shift g2 one position left, then xor with g1.
135 return g1 ^ (g2 << 1);
136 };

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


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.