pixi.js
    Preparing search index...

    Class Pool<T>Advanced

    A generic class for managing a pool of items.

    Type Parameters

    Index

    Constructors

    Accessors

    • get totalFree(): number

      Gets the number of items in the pool that are free to use without needing to create more.

      Returns number

    • get totalSize(): number

      Gets the number of items in the pool.

      Returns number

    • get totalUsed(): number

      Gets the number of items in the pool that are currently in use.

      Returns number

    Methods

    • clears the pool - mainly used for debugging!

      Returns void

    • Gets an item from the pool. Calls the item's init method if it exists. If there are no items left in the pool, a new one will be created.

      Parameters

      • Optionaldata: unknown

        Optional data to pass to the item's constructor.

      Returns T

      The item from the pool.

    • Prepopulates the pool with a given number of items.

      Parameters

      • total: number

        The number of items to add to the pool.

      Returns void

    • Returns an item to the pool. Calls the item's reset method if it exists.

      Parameters

      • item: T

        The item to return to the pool.

      Returns void