Class InstanceRecycler<I extends Instance>
java.lang.Object
dev.engine_room.flywheel.lib.visual.util.InstanceRecycler<I>
- Type Parameters:
I- The type of instance to recycle.
A utility for recycling instances.
If the exact number of instances you need each frame is unknown, you can use this to manage a pool of instances that will be dynamically created, deleted, or re-used as necessary.
If the exact number of instances you need each frame is unknown, you can use this to manage a pool of instances that will be dynamically created, deleted, or re-used as necessary.
-
Constructor Details
-
InstanceRecycler
-
-
Method Details
-
resetCount
public void resetCount()Reset the count of instances.
Call this at before your first call toget()each frame. -
get
Get the next instance in the pool, creating a new one if necessary.
The returned instance may not be in its default state.- Returns:
- The next instance in the pool.
-
discardExtra
public void discardExtra()Delete any instances that were not used this frame.
Call this after your last call toget()each frame. -
delete
public void delete()
-