ValueIndex<T, TKey>
The value index of component T in one world (World.Index). The ValueIndex<T, TKey> class of EasyEcs, the C# ECS: its members, parameters and complexity.
public sealed class ValueIndex<T, TKey> where T : struct, IComponent, IIndexed<TKey> where TKey : IEquatable<TKey>The value index of component T in one world (World.Index). It is kept current as values are written: Set and CreateEntity re-index the entity at once (O(1)), and entities leave it as soon as they are destroyed or lose the component, so a lookup does no catching up. The first lookup (and the first after World.Restore) indexes every row once. Lookups allocate nothing once every key has been seen; the index belongs to the world's owner thread, like component values (systems that look up from OnUpdate or instance methods run alone).
Methods
Count
public int Count(TKey key);Number of entities with key key: O(1) (a hash probe, or an array access for a relation to an entity of this world; the first lookup indexes every row once).
Complexity (API table): O(1)
Find
public ValueIndex<T, TKey>.Matches Find(TKey key);The entities whose T has key key (none for a null key): O(1), then O(1) per entity (the first lookup indexes every row once). Owner thread only. Destroying entities during the loop is allowed; changing T is not (an emptied key hands its list to the keys that grow next): collect the entities first, then change them.
Complexity (API table): O(1), then O(1) per entity
TryFind
public bool TryFind(TKey key, out Entity entity);The first entity found with key key (any, when several have it).
Complexity (API table): O(1)
Last updated on
How is this guide?
UpdateInGroupAttribute<TGroup>
Puts the system (and derived systems) into group TGroup. The UpdateInGroupAttribute<TGroup> class of EasyEcs, the C# ECS.
ValueIndex<T, TKey>.Matches
Enumerates the entities of one key (foreach). The ValueIndex<T, TKey>.Matches struct of EasyEcs, the C# ECS: its members, parameters and complexity.