com.bulletphysics.util
Class ArrayPool<T>

java.lang.Object
  extended by com.bulletphysics.util.ArrayPool<T>

public class ArrayPool<T>
extends Object

Object pool for arrays.


Constructor Summary
ArrayPool(Class componentType)
          Creates object pool.
 
Method Summary
static void cleanCurrentThread()
           
static
<T> ArrayPool<T>
get(Class cls)
          Returns per-thread array pool for given type, or create one if it doesn't exist.
 T getAtLeast(int length)
          Returns array that has same or greater length, or create one if not present in the pool.
 T getFixed(int length)
          Returns array of exactly the same length as demanded, or create one if not present in the pool.
 void release(T array)
          Releases array into object pool.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArrayPool

public ArrayPool(Class componentType)
Creates object pool.

Parameters:
componentType -
Method Detail

getFixed

public T getFixed(int length)
Returns array of exactly the same length as demanded, or create one if not present in the pool.

Parameters:
length -
Returns:
array

getAtLeast

public T getAtLeast(int length)
Returns array that has same or greater length, or create one if not present in the pool.

Parameters:
length - the minimum length required
Returns:
array

release

public void release(T array)
Releases array into object pool.

Parameters:
array - previously obtained array from this pool

get

public static <T> ArrayPool<T> get(Class cls)
Returns per-thread array pool for given type, or create one if it doesn't exist.

Parameters:
cls - type
Returns:
object pool

cleanCurrentThread

public static void cleanCurrentThread()