Skip to main content

Class: SparseSet<T>

Defined in: utilities/sparse-set.ts:4

A sparse set implementation for efficient storage of components in an ECS architecture.

Type Parameters

T

T

Constructors

Constructor

new SparseSet<T>(isTag): SparseSet<T>

Defined in: utilities/sparse-set.ts:14

Creates a new SparseSet instance.

Parameters

isTag

boolean = false

Indicates whether the set is a tag component (default: false).

Returns

SparseSet<T>

Properties

denseComponents

readonly denseComponents: T[]

Defined in: utilities/sparse-set.ts:7


denseEntities

readonly denseEntities: number[]

Defined in: utilities/sparse-set.ts:6


isTag

readonly isTag: boolean

Defined in: utilities/sparse-set.ts:8


sparseArray

readonly sparseArray: number[]

Defined in: utilities/sparse-set.ts:5

Accessors

size

Get Signature

get size(): number

Defined in: utilities/sparse-set.ts:85

Returns

number

Methods

add()

add(entity, component): void

Defined in: utilities/sparse-set.ts:50

Adds a component for the specified entity.

Parameters

entity

number

The entity ID to add the component for.

component

T

The component to add.

Returns

void


get()

get(entity): null | T

Defined in: utilities/sparse-set.ts:39

Gets the component for the specified entity.

Parameters

entity

number

The entity ID to get the component for.

Returns

null | T

The component if the entity has one in the set, null otherwise.


has()

has(entity): boolean

Defined in: utilities/sparse-set.ts:26

Checks if the set contains a component for the specified entity.

Parameters

entity

number

The entity ID to check.

Returns

boolean

True if the entity has a component in the set, false otherwise.


remove()

remove(entity): void

Defined in: utilities/sparse-set.ts:67

Removes the component for the specified entity.

Parameters

entity

number

The entity ID to remove the component for.

Returns

void