HandleMultiMap Class Template
Stores a one-to-many relation between handle domains. More...
Declaration
Public Member Functions Index
template <typename TOneHandle, typename TManyHandle> | |
| ConstIterator | begin () const noexcept |
|
Returns an iterator to the first dense binding. More... | |
template <typename TOneHandle, typename TManyHandle> | |
| ConstIterator | end () const noexcept |
|
Returns the end iterator for dense binding iteration. More... | |
template <typename TOneEntity, typename TManyEntity> | |
| bool | bind (TOneEntity oneEntity, TManyEntity manyEntity) |
|
Binds two entities by forwarding their handles. More... | |
template <typename TOneHandle, typename TManyHandle> | |
| bool | bind (const TOneHandle key, const TManyHandle value) |
|
Binds a value handle to a key handle. More... | |
template <typename TOneHandle, typename TManyHandle> | |
| TOneHandle | key (const TManyHandle value) const noexcept |
|
Returns the owning key handle for a value handle. More... | |
template <typename TOneHandle, typename TManyHandle> | |
| auto | values (const TOneHandle key) const noexcept -> std::span< const TManyHandle > |
|
Returns all value handles bound to a key handle. More... | |
template <typename TOneHandle, typename TManyHandle> | |
| void | clear () |
|
Removes all bindings and clears all internal lookup structures. More... | |
template <typename TOneHandle, typename TManyHandle> | |
| void | reserve (std::size_t keyCapacity, std::size_t valueCapacity) |
|
Reserves capacity for dense key/value storage. More... | |
Private Member Attributes Index
template <typename TOneHandle, typename TManyHandle> | |
| std::vector< std::vector< TManyHandle > > | values_ |
|
Forward mapping from key handle id to associated value handles. More... | |
template <typename TOneHandle, typename TManyHandle> | |
| std::vector< TOneHandle > | keys_ |
|
Reverse mapping from value handle id to owning key handle. More... | |
template <typename TOneHandle, typename TManyHandle> | |
| std::vector< TManyHandle > | denseValues_ |
|
Dense list of all currently bound value handles. More... | |
Description
Stores a one-to-many relation between handle domains.
The map keeps two dense lookup structures:
- values_: key handle id -> list of associated value handles.
- keys_: value handle id -> owning key handle.
The implementation uses entityId as direct index and therefore expects stable id semantics for both handle types.
- Template Parameters
-
TOneHandle Handle type representing the "one" side.
TManyHandle Handle type representing the "many" side.
Definition at line 35 of file HandleMultiMap.ixx.
Public Member Functions
begin()
| inline noexcept |
Returns an iterator to the first dense binding.
Definition at line 131 of file HandleMultiMap.ixx.
bind()
| inline |
Binds two entities by forwarding their handles.
- Template Parameters
-
TOneEntity Entity type on the "one" side.
TManyEntity Entity type on the "many" side.
- Parameters
-
oneEntity Entity owning the relation.
manyEntity Entity associated with the owner.
- Returns
true if the binding was inserted, otherwise false.
Definition at line 151 of file HandleMultiMap.ixx.
References helios::engine::core::container::HandleMultiMap< TOneHandle, TManyHandle >::bind and helios::registerComponents.
Referenced by helios::engine::core::container::HandleMultiMap< TOneHandle, TManyHandle >::bind.
bind()
| inline |
Binds a value handle to a key handle.
Inserts the value into the key bucket and stores reverse ownership in keys_. Returns false if the value is already bound.
- Parameters
-
key Key handle on the "one" side.
value Value handle on the "many" side.
- Returns
true if the binding was inserted, otherwise false.
Definition at line 166 of file HandleMultiMap.ixx.
References helios::engine::core::container::HandleMultiMap< TOneHandle, TManyHandle >::key and helios::registerComponents.
clear()
| inline |
Removes all bindings and clears all internal lookup structures.
Definition at line 232 of file HandleMultiMap.ixx.
end()
| inline noexcept |
Returns the end iterator for dense binding iteration.
Definition at line 136 of file HandleMultiMap.ixx.
key()
| inline noexcept |
Returns the owning key handle for a value handle.
- Parameters
-
value Value handle from the "many" side.
- Returns
Owning key handle, or default-constructed handle if not found.
Definition at line 203 of file HandleMultiMap.ixx.
Reference helios::registerComponents.
Referenced by helios::engine::core::container::HandleMultiMap< TOneHandle, TManyHandle >::bind and helios::engine::core::container::HandleMultiMap< TOneHandle, TManyHandle >::values.
reserve()
| inline |
Reserves capacity for dense key/value storage.
- Parameters
-
keyCapacity Expected number of distinct keys.
valueCapacity Expected number of bound values.
Definition at line 244 of file HandleMultiMap.ixx.
Reference helios::registerComponents.
values()
| inline noexcept |
Returns all value handles bound to a key handle.
- Parameters
-
key Key handle from the "one" side.
- Returns
Read-only span of associated value handles. Empty if key is unknown.
Definition at line 220 of file HandleMultiMap.ixx.
References helios::engine::core::container::HandleMultiMap< TOneHandle, TManyHandle >::key and helios::registerComponents.
Private Member Attributes
denseValues_
|
Dense list of all currently bound value handles.
Used by the iterator to avoid scanning holes in keys_.
Definition at line 52 of file HandleMultiMap.ixx.
keys_
|
Reverse mapping from value handle id to owning key handle.
Definition at line 45 of file HandleMultiMap.ixx.
values_
|
Forward mapping from key handle id to associated value handles.
Definition at line 40 of file HandleMultiMap.ixx.
The documentation for this class was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.