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 26 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 40 of file HashedLookupStrategy.ixx.

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

Public Member Functions

add()

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

Registers a strong ID.

Parameters
id

The strong ID to add.

Returns

True if inserted, false if already present.

Definition at line 51 of file HashedLookupStrategy.ixx.

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

has()

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

Checks whether a strong ID is registered.

Parameters
id

The strong ID to test.

Returns

True if the ID is present.

Definition at line 73 of file HashedLookupStrategy.ixx.

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

remove()

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

Removes a strong ID.

Parameters
id

The strong ID to remove.

Returns

True if removed, false if not found.

Definition at line 62 of file HashedLookupStrategy.ixx.

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

Private Member Attributes

strongIds_

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

Set of registered strong IDs.

Definition at line 31 of file HashedLookupStrategy.ixx.

31 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.15.0.