UNPKG

@nativescript-community/ui-chart

Version:

A powerful chart / graph plugin, supporting line, bar, pie, radar, bubble, and candlestick charts as well as scaling, panning and animations.

82 lines (81 loc) 3.12 kB
export declare abstract class Poolable { static mNO_OWNER: number; mCurrentOwnerId: number; abstract instantiate(): Poolable; } /** * An object pool for recycling of object instances extending Poolable. * * * Cost/Benefit : * Cost - The pool can only contain objects extending Poolable. * Benefit - The pool can very quickly determine if an object is elligable for storage without iteration. * Benefit - The pool can also know if an instance of Poolable is already stored in a different pool instance. * Benefit - The pool can grow as needed, if it is empty * Cost - However, refilling the pool when it is empty might incur a time cost with sufficiently large capacity. Set the replenishPercentage to a lower number if this is a concern. * * Created by Tony Patino on 6/20/16. */ export declare class ObjectPool<T extends Poolable> { private static mIds; private mPoolId; private mDesiredCapacity; private mObjects; private mObjectsPointer; private mModelObject; private mReplenishPercentage; /** * Returns the id of the given pool instance. * * @return an integer ID belonging to this pool instance. */ getPoolId(): any; /** * Returns an ObjectPool instance, of a given starting capacity, that recycles instances of a given Poolable object. * * @param withCapacity A positive integer value. * @param object An instance of the object that the pool should recycle. * @return */ static create<T extends Poolable>(withCapacity: any, object: T): ObjectPool<T>; constructor(withCapacity: any, object: T); /** * Set the percentage of the pool to replenish on empty. Valid values are between * 0.00 and 1.00 * * @param percentage a value between 0 and 1, representing the percentage of the pool to replenish. */ setReplenishPercentage(percentage: any): this; getReplenishPercentage(): any; private refillPool; /** * Returns an instance of Poolable. If get() is called with an empty pool, the pool will be * replenished. If the pool capacity is sufficiently large, this could come at a performance * cost. * * @return An instance of Poolable object T */ get(): T; /** * Recycle an instance of Poolable that this pool is capable of generating. * The T instance passed must not already exist inside this or any other ObjectPool instance. * * @param object An object of type T to recycle */ recycle(object: T | T[]): void; private resizePool; /** * Returns the capacity of this object pool. Note : The pool will automatically resize * to contain additional objects if the user tries to add more objects than the pool's * capacity allows, but this comes at a performance cost. * * @return The capacity of the pool. */ getPoolCapacity(): number; /** * Returns the number of objects remaining in the pool, for diagnostic purposes. * * @return The number of objects remaining in the pool. */ getPoolCount(): any; }