Packagestarling.utils
Classpublic class Pool
InheritancePool Inheritance Object

A simple object pool supporting the most basic utility objects.

If you want to retrieve an object, but the pool does not contain any more instances, it will silently create a new one.

It's important that you use the pool in a balanced way, i.e. don't just "get" or "put" alone! Always make the calls in pairs; whenever you get an object, be sure to put it back later, and the other way round. Otherwise, the pool will empty or (even worse) grow in size uncontrolled.



Public Methods
 MethodDefined By
  
getArray():Array
[static] Retrieves an Array instance from the pool.
Pool
  
getMatrix(a:Number = 1, b:Number = 0, c:Number = 0, d:Number = 1, tx:Number = 0, ty:Number = 0):Matrix
[static] Retrieves a Matrix instance from the pool.
Pool
  
getMatrix3D(identity:Boolean = true):Matrix3D
[static] Retrieves a Matrix3D instance from the pool.
Pool
  
getPoint(x:Number = 0, y:Number = 0):Point
[static] Retrieves a Point instance from the pool.
Pool
  
getPoint3D(x:Number = 0, y:Number = 0, z:Number = 0):Vector3D
[static] Retrieves a Vector3D instance from the pool.
Pool
  
getRectangle(x:Number = 0, y:Number = 0, width:Number = 0, height:Number = 0):Rectangle
[static] Retrieves a Rectangle instance from the pool.
Pool
  
putArray(array:Array):void
[static] Stores an Array instance in the pool (after purging it).
Pool
  
putMatrix(matrix:Matrix):void
[static] Stores a Matrix instance in the pool.
Pool
  
putMatrix3D(matrix:Matrix3D):void
[static] Stores a Matrix3D instance in the pool.
Pool
  
putPoint(point:Point):void
[static] Stores a Point instance in the pool.
Pool
  
putPoint3D(point:Vector3D):void
[static] Stores a Vector3D instance in the pool.
Pool
  
putRectangle(rectangle:Rectangle):void
[static] Stores a Rectangle instance in the pool.
Pool
Method Detail
getArray()method
public static function getArray():Array

Retrieves an Array instance from the pool.

Returns
Array
getMatrix()method 
public static function getMatrix(a:Number = 1, b:Number = 0, c:Number = 0, d:Number = 1, tx:Number = 0, ty:Number = 0):Matrix

Retrieves a Matrix instance from the pool.

Parameters

a:Number (default = 1)
 
b:Number (default = 0)
 
c:Number (default = 0)
 
d:Number (default = 1)
 
tx:Number (default = 0)
 
ty:Number (default = 0)

Returns
Matrix
getMatrix3D()method 
public static function getMatrix3D(identity:Boolean = true):Matrix3D

Retrieves a Matrix3D instance from the pool.

Parameters

identity:Boolean (default = true) — If enabled, the matrix will be reset to the identity. Otherwise, its contents is undefined.

Returns
Matrix3D
getPoint()method 
public static function getPoint(x:Number = 0, y:Number = 0):Point

Retrieves a Point instance from the pool.

Parameters

x:Number (default = 0)
 
y:Number (default = 0)

Returns
Point
getPoint3D()method 
public static function getPoint3D(x:Number = 0, y:Number = 0, z:Number = 0):Vector3D

Retrieves a Vector3D instance from the pool.

Parameters

x:Number (default = 0)
 
y:Number (default = 0)
 
z:Number (default = 0)

Returns
Vector3D
getRectangle()method 
public static function getRectangle(x:Number = 0, y:Number = 0, width:Number = 0, height:Number = 0):Rectangle

Retrieves a Rectangle instance from the pool.

Parameters

x:Number (default = 0)
 
y:Number (default = 0)
 
width:Number (default = 0)
 
height:Number (default = 0)

Returns
Rectangle
putArray()method 
public static function putArray(array:Array):void

Stores an Array instance in the pool (after purging it). Don't keep any references to the array after moving it to the pool!

Parameters

array:Array

putMatrix()method 
public static function putMatrix(matrix:Matrix):void

Stores a Matrix instance in the pool. Don't keep any references to the object after moving it to the pool!

Parameters

matrix:Matrix

putMatrix3D()method 
public static function putMatrix3D(matrix:Matrix3D):void

Stores a Matrix3D instance in the pool. Don't keep any references to the object after moving it to the pool!

Parameters

matrix:Matrix3D

putPoint()method 
public static function putPoint(point:Point):void

Stores a Point instance in the pool. Don't keep any references to the object after moving it to the pool!

Parameters

point:Point

putPoint3D()method 
public static function putPoint3D(point:Vector3D):void

Stores a Vector3D instance in the pool. Don't keep any references to the object after moving it to the pool!

Parameters

point:Vector3D

putRectangle()method 
public static function putRectangle(rectangle:Rectangle):void

Stores a Rectangle instance in the pool. Don't keep any references to the object after moving it to the pool!

Parameters

rectangle:Rectangle