Skip to main content
Module

x/structurae/pool.ts>Pool

Data structures for high-performance JavaScript applications.
Latest
class Pool
extends BitArray
import { Pool } from "https://deno.land/x/structurae@4.0.1/pool.ts";

Implements a fast algorithm to manage availability of objects in an object pool using a BitArray.

Examples

// create a pool of 1600 indexes const pool = Pool.create(100 * 16);

// get the next available index and make it unavailable pool.get(); //=> 0 pool.get(); //=> 1

// set index available pool.free(0); pool.get(); //=> 0

pool.get(); //=> 2

Properties

nextAvailable: number

Methods

free(index: number): void

Makes a given index available.

get(): number

Gets the next available index in the pool.

Static Methods

create<T extends BitArray>(this: T, size: number): InstanceType<T>

Creates a Pool of the specified size.