/** @packageDocumentation * @module ArraysAndInterfaces */ import { GrowableXYZArray } from "./GrowableXYZArray"; import { IndexedXYZCollection } from "./IndexedXYZCollection"; /** * Abstract class managing an array of objects of type T, available for reuse by trusted callers. * * Derived class must implement `createForCache` and `clearForCache`. * @public */ export declare abstract class ReusableObjectCache { private _cachedObjects; private _numDrop; private _numCreate; private _numReuse; /** * Create a new cache for objects of type T. */ protected constructor(); /** Create a new, ready-to-use object. */ protected abstract createForCache(): T; /** Tidy up `data` so it can be reused. */ protected abstract clearForCache(data: T): void; /** * Present `data` for storage in the cache, and hence reuse by any subsequent [[grabFromCache]]. * * `data` will be sent to [[clearForCache]]. * * The caller should never refer to `data` again. * @param data object to return to the cache. */ dropToCache(data: T | undefined): void; /** * Grab an object from the cache. * * The returned object becomes property of the caller: the cache does not remember it for any further management. */ grabFromCache(): T; /** * Drop multiple objects to the cache. * @param data on input, the data to drop. On output, data is an empty array. */ dropAllToCache(data: T[]): void; } /** * Cache of [[GrowableXYZArray]]. * * Example usage includes clipping methods that can be structured to have disciplined reuse of a small number of arrays for a large number of steps. * @public */ export declare class GrowableXYZArrayCache extends ReusableObjectCache { /** * Create a new cache for [[GrowableXYZArray]] objects. */ constructor(); /** * Create a new, ready-to-use [[GrowableXYZArray]]. * @param numPoints initial capacity in xyz triples (default 10) * @param growthFactor reallocation expansion (default 1.5) */ protected createForCache(numPoints?: number, growthFactor?: number): GrowableXYZArray; /** Tidy up `data` so it can be reused. */ protected clearForCache(data: GrowableXYZArray): void; /** * Grab an array from the cache and immediately fill from a source. * @param source xyz to copy into the returned array. */ grabAndFill(source: IndexedXYZCollection): GrowableXYZArray; } //# sourceMappingURL=ReusableObjectCache.d.ts.map