|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.badlogic.gdx.utils.Pool<T>
public abstract class Pool<T>
A pool of objects that can be reused to avoid allocation.
Nested Class Summary | |
---|---|
static interface |
Pool.Poolable
Objects implementing this interface will have Pool.Poolable.reset() called when passed to free(Object) . |
Field Summary | |
---|---|
int |
max
The maximum number of objects that will be pooled. |
int |
peak
The highest number of free objects. |
Constructor Summary | |
---|---|
Pool()
Creates a pool with an initial capacity of 16 and no maximum. |
|
Pool(int initialCapacity)
Creates a pool with the specified initial capacity and no maximum. |
|
Pool(int initialCapacity,
int max)
|
Method Summary | |
---|---|
void |
clear()
Removes all free objects from this pool. |
void |
free(T object)
Puts the specified object in the pool, making it eligible to be returned by obtain() . |
void |
freeAll(Array<T> objects)
Puts the specified objects in the pool. |
int |
getFree()
The number of objects available to be obtained. |
T |
obtain()
Returns an object from this pool. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public final int max
public int peak
Constructor Detail |
---|
public Pool()
public Pool(int initialCapacity)
public Pool(int initialCapacity, int max)
max
- The maximum number of free objects to store in this pool.Method Detail |
---|
public T obtain()
newObject()
) or reused (previously
freed
).
public void free(T object)
obtain()
. If the pool already contains
max
free objects, the specified object is reset but not added to the pool.
public void freeAll(Array<T> objects)
free(Object)
public void clear()
public int getFree()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |