Skip to main content

HashedLookupStrategy Class

Lookup strategy using an unordered set for O(1) amortized lookups. More...

Declaration​

class helios::ecs::strategies::HashedLookupStrategy { ... }

Public Constructors Index​

HashedLookupStrategy (const size_t capacity)

Constructs a strategy with pre-allocated capacity. More...

Public Member Functions Index​

booladd (const StrongId_t id)

Registers a strong ID. More...

boolremove (const StrongId_t id)

Removes a strong ID. More...

boolhas (const StrongId_t id) const

Checks whether a strong ID is registered. More...

Private Member Attributes Index​

std::unordered_set< StrongId_t >strongIds_

Set of registered strong IDs. More...

Description​

Lookup strategy using an unordered set for O(1) amortized lookups.

HashedLookupStrategy maintains a set of registered strong IDs and provides constant-time insertion, removal, and membership tests. Used as the default lookup strategy in EntityRegistry.

See Also

EntityRegistry

See Also

LinearLookupStrategy

Definition at line 27 of file HashedLookupStrategy.ixx.

Public Constructors​

HashedLookupStrategy()​

helios::ecs::strategies::HashedLookupStrategy::HashedLookupStrategy (const size_t capacity)
inline explicit

Constructs a strategy with pre-allocated capacity.

Parameters
capacity

The initial bucket count to reserve.

Definition at line 41 of file HashedLookupStrategy.ixx.

41 explicit HashedLookupStrategy(const size_t capacity) {
42 strongIds_.reserve(capacity);
43 };

Public Member Functions​

add()​

bool helios::ecs::strategies::HashedLookupStrategy::add (const StrongId_t id)
inline

Registers a strong ID.

Parameters
id

The strong ID to add.

Returns

True if inserted, false if already present.

Definition at line 52 of file HashedLookupStrategy.ixx.

52 [[nodiscard]] bool add(const StrongId_t id) {
53 return strongIds_.insert(id).second;
54 }

has()​

bool helios::ecs::strategies::HashedLookupStrategy::has (const StrongId_t id)
inline

Checks whether a strong ID is registered.

Parameters
id

The strong ID to test.

Returns

True if the ID is present.

Definition at line 74 of file HashedLookupStrategy.ixx.

74 [[nodiscard]] bool has(const StrongId_t id) const {
75 return strongIds_.contains(id);
76 }

remove()​

bool helios::ecs::strategies::HashedLookupStrategy::remove (const StrongId_t id)
inline

Removes a strong ID.

Parameters
id

The strong ID to remove.

Returns

True if removed, false if not found.

Definition at line 63 of file HashedLookupStrategy.ixx.

63 [[nodiscard]] bool remove(const StrongId_t id) {
64 return strongIds_.erase(id) > 0;
65 }

Private Member Attributes​

strongIds_​

std::unordered_set<StrongId_t> helios::ecs::strategies::HashedLookupStrategy::strongIds_

Set of registered strong IDs.

Definition at line 32 of file HashedLookupStrategy.ixx.

32 std::unordered_set<StrongId_t> strongIds_;

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


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.