Skip to content

EntityIdentifierGenerator

ctreffs edited this page Oct 7, 2020 · 4 revisions

EntityIdentifierGenerator

Entity Identifier Generator

public protocol EntityIdentifierGenerator

An entity identifier generator provides new entity identifiers on entity creation. It also allows entity ids to be marked as unused (to be re-usable).

You should strive to keep entity ids tightly packed around EntityIdentifier.Identifier.min since it has an influence on the underlying memory layout.

Requirements

nextId()

Provides the next unused entity identifier.

func nextId() -> EntityIdentifier

The provided entity identifier must be unique during runtime.

markUnused(entityId:​)

Marks the given entity identifier as free and ready for re-use.

func markUnused(entityId: EntityIdentifier)

Unused entity identifiers will again be provided with nextId().

Parameters

  • entityId: The entity id to be marked as unused.
Clone this wiki locally