Skip to content

Instantly share code, notes, and snippets.

@FrancescoMaisto
Forked from JulianG/ObjectPool.as
Created January 5, 2013 10:21
Show Gist options
  • Save FrancescoMaisto/4460874 to your computer and use it in GitHub Desktop.
Save FrancescoMaisto/4460874 to your computer and use it in GitHub Desktop.
ObjectPool class forked from Julian's class
package
{
/**
* ObjectPool Class
* @author Julian
*/
public class ObjectPool
{
private var _list:Array;
public function ObjectPool(object_type:Class, qty:uint)
{
for (var i:int = 0; i < qty; i++)
{
_list.push( new object_type() );
}
}
public function getNextObject():*
{
var obj:* = _list.shift();
_list.push(obj);
return obj;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment