Package com.badlogic.gdx.utils
Class Pools
java.lang.Object
com.badlogic.gdx.utils.Pools
Stores a map of
Pool
s by type for convenient static access.-
Method Summary
Modifier and TypeMethodDescriptionstatic void
Frees an object from thepool
.static void
Frees the specified objects from thepool
.static void
Frees the specified objects from thepool
.static <T> Pool<T>
get
(DefaultPool.PoolSupplier<T> poolTypeSupplier) Returns a new or existing pool for the specified type, stored in a Class toPool
map.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 toPool
map.static <T> Pool<T>
Deprecated.static <T> Pool<T>
Deprecated.Useget(PoolSupplier, int)
insteadstatic <T> T
obtain
(DefaultPool.PoolSupplier<T> poolTypeSupplier) Obtains an object from theget(PoolSupplier)
pool.static <T> T
Deprecated.static <T> void
Sets an existing pool for the specified type, stored in a Class toPool
map.
-
Method Details
-
get
Deprecated.Useget(PoolSupplier, int)
insteadReturns a new or existing pool for the specified type, stored in a Class toPool
map. Note the max size is ignored if this is not the first time this pool has been requested. -
get
Deprecated.Useget(PoolSupplier)
insteadReturns a new or existing pool for the specified type, stored in a Class toPool
map. The max size of the pool used is 100. -
get
Returns a new or existing pool for the specified type, stored in a Class toPool
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
Returns a new or existing pool for the specified type, stored in a Class toPool
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
Sets an existing pool for the specified type, stored in a Class toPool
map. -
obtain
Obtains an object from theget(PoolSupplier)
pool.
Usage can use java 8 method references:Pools.obtain(MyClass::new)
-
obtain
Deprecated.Obtains an object from thepool
. -
free
Frees an object from thepool
. -
freeAll
Frees the specified objects from thepool
. Null objects within the array are silently ignored. Objects don't need to be from the same pool. -
freeAll
Frees the specified objects from thepool
. 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.
-
get(PoolSupplier)
instead