SessionPool
Class: SessionPool
Defined in: engine/pool.ts:10
Session-scoped instance pool. Holds every instance generated during one
generate() / generateGraph() call so that later relation-aware fields
(@ModelLink, @ModelRelated) can reference real earlier instances rather
than made-up ids.
All randomness is driven by the constructor-injected rng: () => number
so outcomes are reproducible when the caller supplies a seeded RNG.
Constructors
Constructor
new SessionPool(
rng?):SessionPool
Defined in: engine/pool.ts:17
Parameters
rng?
() => number
deterministic RNG returning a float in [0, 1). Defaults to
Math.random when no seed is needed.
Returns
SessionPool
Methods
add()
add(
instance):void
Defined in: engine/pool.ts:24
Add an instance to the pool, keyed by its constructor.
Parameters
instance
unknown
the object to add. Non-objects are ignored.
Returns
void
pickMany()
pickMany<
T>(ctor,count):T[]
Defined in: engine/pool.ts:55
Pick a unique subset of instances of the given class.
Type Parameters
T
T
Parameters
ctor
(...args) => T
the class to pick from.
count
number
requested subset size; clamped to pool.size(ctor).
Returns
T[]
the selected instances (may be shorter than count).
pickOne()
pickOne<
T>(ctor):T
Defined in: engine/pool.ts:41
Pick one random instance of the given class from the pool.
Type Parameters
T
T
Parameters
ctor
(...args) => T
the class to pick an instance of.
Returns
T
a pooled instance, or null when the pool has none.
size()
size(
ctor):number
Defined in: engine/pool.ts:77
Number of pooled instances of the given class.
Parameters
ctor
(...args) => unknown
the class to count.
Returns
number
the current pool size for that class (0 when absent).