Nativescript plugin for Charts
    Preparing search index...

    Class ObjectPool<T>

    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.

    Type Parameters

    Index

    Constructors

    • Type Parameters

      Parameters

      • withCapacity: any
      • object: T

      Returns ObjectPool<T>

    Methods

    • 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.

      Returns T

      An instance of Poolable object T

    • 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.

      Returns number

      The capacity of the pool.

    • Returns the number of objects remaining in the pool, for diagnostic purposes.

      Returns any

      The number of objects remaining in the pool.

    • Returns the id of the given pool instance.

      Returns any

      an integer ID belonging to this pool instance.

    • Returns any

    • 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.

      Parameters

      • object: T | T[]

        An object of type T to recycle

      Returns void

    • Set the percentage of the pool to replenish on empty. Valid values are between 0.00 and 1.00

      Parameters

      • percentage: any

        a value between 0 and 1, representing the percentage of the pool to replenish.

      Returns this

    • Returns an ObjectPool instance, of a given starting capacity, that recycles instances of a given Poolable object.

      Type Parameters

      Parameters

      • withCapacity: any

        A positive integer value.

      • object: T

        An instance of the object that the pool should recycle.

      Returns ObjectPool<T>