public abstract class Pool<T>
extends java.lang.Object
Pool
限定符和类型 | 类和说明 |
---|---|
static interface |
Pool.Poolable
Objects implementing this interface will have
Pool.Poolable.reset() called when passed to free(Object) . |
限定符和类型 | 字段和说明 |
---|---|
int |
max
The maximum number of objects that will be pooled.
|
int |
peak
The highest number of free objects.
|
构造器和说明 |
---|
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) |
限定符和类型 | 方法和说明 |
---|---|
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.
|
protected abstract T |
newObject() |
T |
obtain()
Returns an object from this pool.
|
protected void |
reset(T object)
Called when an object is freed to clear the state of the object for possible later reuse.
|
public final int max
public int peak
public Pool()
public Pool(int initialCapacity)
public Pool(int initialCapacity, int max)
max
- The maximum number of free objects to store in this pool.protected abstract T newObject()
public T obtain()
newObject()
) or reused (previously
freed
).public void free(T object)
protected void reset(T object)
Pool.Poolable.reset()
if the object is Pool.Poolable
.public void freeAll(Array<T> objects)
free(Object)
public void clear()
public int getFree()