import type { EntityHandle, HandleLayout } from './codec.js'; export declare class CapacityExceeded extends Error { readonly name = "CapacityExceeded"; constructor(capacity: number, aliveCount: number); } /** * Asked of the store when a brand-new index would exceed the currently-addressable array * length. Returns the new addressable length after growth; returns the * unchanged length when growth is impossible, which makes `allocEntity` throw CapacityExceeded. */ export type GrowHook = (need: number) => number; export interface EntityIndexArrays { /** sparse[index] = position of `index` within `dense`. */ readonly sparse: Uint32Array; /** dense[pos] = a full EntityHandle; [0, aliveCount) alive, [aliveCount, denseLen) parked-free. */ readonly dense: Uint32Array; /** Per-slot generation, addressed by index (only low generationBits used). */ readonly generation: Uint32Array; } /** Tuning for the mint-time bounds: how many indices are addressable now vs. ever allowed. */ export interface EntityIndexBounds { /** Current addressable array length (grows via the GrowHook up to `ceiling`). */ readonly addressable: number; /** * Hard mint ceiling: the largest number of distinct indices that may ever be minted. The * allocator throws CapacityExceeded once denseLen reaches this with no free slot. Typically * `min(maxEntities, maxIndex + 1)`, minus one when threaded to reserve `maxIndex` for the * NO_ENTITY sentinel. */ readonly ceiling: number; } export declare class EntityIndex { #private; constructor(layout: HandleLayout, arrays: EntityIndexArrays, bounds?: EntityIndexBounds, grow?: GrowHook); /** Re-publish the backing arrays after a growth; positions/cursors are unchanged. */ rebind(arrays: EntityIndexArrays, addressable: number): void; get aliveCount(): number; get denseLen(): number; get totalSpawned(): number; get totalDespawned(): number; get wrapped(): boolean; /** * ROLLBACK-ONLY (@ecsia/rollback restore): rewind the four cursors to a captured * checkpoint. Restoring the sparse/dense/generation regions WITHOUT rewinding these leaves the * allocator minting past where the checkpoint ended (and `aliveCount === spawned - despawned` * broken). Serial-phase only. */ restoreCursors(aliveCount: number, denseLen: number, spawned: number, despawned: number): void; allocEntity(): EntityHandle; freeEntity(handle: EntityHandle): void; /** The full (generational) handle currently occupying `index`, or NO_ENTITY-equivalent if dead. */ handleOfIndex(index: number): EntityHandle; isAlive(handle: EntityHandle): boolean; } //# sourceMappingURL=index-allocator.d.ts.map