Class Pools

java.lang.Object
com.badlogic.gdx.utils.Pools

public class Pools extends Object
Stores a map of Pools by type for convenient static access.
  • Method Details

    • get

      @Deprecated public static <T> Pool<T> get(Class<T> type, int max)
      Deprecated.
      Returns a new or existing pool for the specified type, stored in a Class to Pool map. Note the max size is ignored if this is not the first time this pool has been requested.
    • get

      @Deprecated public static <T> Pool<T> get(Class<T> type)
      Deprecated.
      Use get(PoolSupplier) instead
      Returns a new or existing pool for the specified type, stored in a Class to Pool map. The max size of the pool used is 100.
    • get

      public static <T> Pool<T> get(DefaultPool.PoolSupplier<T> poolTypeSupplier, int max)
      Returns a new or existing pool for the specified type, stored in a Class to Pool map. Note the max size is ignored if this is not the first time this pool has been requested. This method may create a temporary object once, but the allocation will probably be eliminated on most platforms.
      Usage can use java 8 method references: Pools.get(MyClass::new, max)
    • get

      public static <T> Pool<T> get(DefaultPool.PoolSupplier<T> poolTypeSupplier)
      Returns a new or existing pool for the specified type, stored in a Class to Pool map. The max size of the pool used is 100. This method may create a temporary object once, but the allocation will probably be eliminated on most platforms.
      Usage can use java 8 method references: Pools.get(MyClass::new)
    • set

      public static <T> void set(Class<T> type, Pool<T> pool)
      Sets an existing pool for the specified type, stored in a Class to Pool map.
    • obtain

      public static <T> T obtain(DefaultPool.PoolSupplier<T> poolTypeSupplier)
      Obtains an object from the get(PoolSupplier) pool.
      Usage can use java 8 method references: Pools.obtain(MyClass::new)
    • obtain

      @Deprecated public static <T> T obtain(Class<T> type)
      Deprecated.
      Obtains an object from the pool.
    • free

      public static void free(Object object)
      Frees an object from the pool.
    • freeAll

      public static void freeAll(Array objects)
      Frees the specified objects from the pool. Null objects within the array are silently ignored. Objects don't need to be from the same pool.
    • freeAll

      public static void freeAll(Array objects, boolean samePool)
      Frees the specified objects from the pool. Null objects within the array are silently ignored.
      Parameters:
      samePool - If true, objects don't need to be from the same pool but the pool must be looked up for each object.