import { LoopableArray } from 'no-more-for-loops'; import { Cleanable, CleanableArray } from './Cleanable'; /** * Pool object with use() and recycle(obj) methods. */ export interface NaivePool { use(): T; recycle(usedObject: T): void; } /** * Object pool which calls the provided function for every element when using & recyling. * Intended to use with the library deePool, but can also be used with another implementation. */ export declare class ObjectPool { /** * Recycles the object. * @param usedObject */ readonly recycle: (usedObject: T) => void; readonly naivePool: NaivePool; protected readonly useProcess: (object: T) => any; protected readonly recycleProcess: (object: T) => any; /** * * @param naivePool - The pool object with use() and recycle(obj) methods. * @param useProcess - The callback function which will be called in use(). * @param recycleProcess - The callback function which will be called in recycle(). */ constructor(naivePool: NaivePool, useProcess?: (object: T) => any, recycleProcess?: (object: T) => any); /** * Returns an object which is currently not in use. */ use(): T; /** * Recycles all elements of the provided array. * @param array */ recycleAll(array: LoopableArray): void; } /** * Array of pooled objects. Recycles every removing object when clean() has been called. */ export declare class PoolableArray extends CleanableArray { readonly pool: ObjectPool; constructor(pool: ObjectPool, initialCapacity?: number); clean(): void; }