-
-
Save FrancescoMaisto/4460874 to your computer and use it in GitHub Desktop.
ObjectPool class forked from Julian's class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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