Helios Engine
A modular ECS based data-oriented C++23 game engine framework
Loading...
Searching...
No Matches
container Directory Reference

Directories

 
include

Detailed Description

`container` — Data-Oriented Containers

Header-only containers used throughout the engine: sparse sets for ECS storage, type-indexed maps for plugin/resource registries, and type-erased buffers for commands and resources.

Public API

Type Purpose
SparseSet<T> O(1) insert/remove/lookup. Sparse + dense + reverse arrays; swap-and-pop removal.
MultiTypeMap<Storage> Type-indexed map keyed by TypeIndex. Ensure<T>(), Get<T>(), ForEach().
TypedBuffer<T> Type-erased single-instance storage. Fast path for trivially-copyable types.
TypedBufferArray<T> Contiguous storage for multiple instances of one type. PMR support.
CallableBuffer<...> Single-instance type-erased callable. Set(), Invoke().
CallableBufferArray<...> Inline array of heterogeneous callables without virtual dispatch.
StaticString<N> Stack-allocated fixed-capacity string (BasicStaticString alias).

SparseSet

set.Insert(42, 100); // index 42 → value 100
set.Insert(7, 200);
CHECK(set.Contains(42));
CHECK_EQ(set.Get(42), 100);
set.Remove(42); // O(1) swap-and-pop
for (int value : set) { // cache-friendly dense iteration
// ...
}
A sparse set data structure for efficient mapping of sparse indices to dense storage of values.
constexpr void Remove(IndexType index) noexcept
Removes an index from the set.
constexpr bool Contains(IndexType index) const noexcept
Checks if an index exists in the set.
constexpr T & Get(IndexType index) noexcept
Gets the value at the specified index.
constexpr DenseIndexType Insert(IndexType index, const T &value)
Inserts a value at the specified index (copy version).

MultiTypeMap

map.Ensure<int>() = "integer slot";
map.Ensure<float>() = "float slot";
map.ForEach([](auto type_index, std::string& value) {
// iterate all registered types
});
Generic type-indexed map that stores one Storage instance per registered type key.
constexpr Storage & Ensure()
Ensures a Storage entry exists for type T and returns a reference to it.

TypedBuffer

buffer.Set<PhysicsConfig>({.gravity = -9.81F});
auto& config = buffer.Value<PhysicsConfig>();
buffer.Reset(); // destroy value and clear type info
buffer.Set<RenderConfig>(); // type can change across lifetimes
Type-erased single-instance byte storage.
T & Value() noexcept
Accesses the stored value.
T & Set(Args &&... args)
Constructs (or replaces) the stored value in-place.
constexpr void Reset() noexcept
Destroys the stored value and resets type information.

CallableBuffer

cmd.Set([](int& x) { x += 1; });
int value = 0;
cmd.Invoke(value);
typename details::CallableBufferDeducer< Args... >::type CallableBuffer
Single-instance callable buffer with type-erased invocation.

Multiple signatures:

helios::container::CallableBuffer<void(World&), void(Logger&)> multi;
multi.Set<&Cmd::Execute, &Cmd::Log>(Cmd{data});
multi.Invoke<0>(world);
multi.Invoke<1>(logger);

StaticString

CHECK_EQ(name.Size(), 6);
CHECK(name == "Player");
BasicStaticString< N, char > StaticString
Fixed-capacity string of char.

No heap allocation — storage lives on the stack.

Dependencies

  • core — asserts
  • utilsTypeIndex for MultiTypeMap
  • External: Boost flat_map (when std::flat_map unavailable)