Package jahuwaldt.js.util
Class SizedObjectFactory<T extends SizedObject>
- java.lang.Object
-
- jahuwaldt.js.util.SizedObjectFactory<T>
-
public abstract class SizedObjectFactory<T extends SizedObject> extends java.lang.Object
This class holds factories to produces objects of variable size/length. It allows for object recycling, pre-allocation and stack allocations:
static SizedObjectFactory
BINOMIAL_FACTORY = new SizedObjectFactory { protected BinomialCoef create(int size) { return new BinomialCoef(size); } }; ... BinomialCoef bin = BINOMIAL_FACTORY.array(256); - Version:
- September 15, 2012
- Author:
- Joseph A. Huwaldt Date: May 11, 2011
-
-
Constructor Summary
Constructors Constructor Description SizedObjectFactory()
Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description T
object(int capacity)
Returns an sized object possibly recycled or preallocated of specified minimum size.void
recycle(SizedObject object)
Recycles the specified sized object.
-
-
-
Constructor Detail
-
SizedObjectFactory
public SizedObjectFactory()
Default constructor.
-
-
Method Detail
-
object
public final T object(int capacity)
Returns an sized object possibly recycled or preallocated of specified minimum size.- Parameters:
capacity
- the minimum size of the array to be returned.- Returns:
- a recycled, pre-allocated or new factory array.
-
recycle
public void recycle(SizedObject object)
Recycles the specified sized object.- Parameters:
object
- the SizedObject to be recycled.
-
-