Class RecycleManager<T>

java.lang.Object
org.ddogleg.struct.RecycleManager<T>
Direct Known Subclasses:
RecycleManagerL

public class RecycleManager<T>
extends Object
Simple class which helps minimize declaring new objects by helping you recycle them.
  • Field Details

    • targetClass

      protected Class<T> targetClass
    • unused

      protected ArrayDeque<T> unused
  • Constructor Details

    • RecycleManager

      public RecycleManager​(Class<T> targetClass)
  • Method Details

    • requestInstance

      public T requestInstance()
      Either returns a recycled instance or a new one.
    • recycleInstance

      public void recycleInstance​(T object)
      Call when an instance is no longer needed and can be recycled
    • createInstance

      protected T createInstance()
      Creates a new instance using the class. overload this to handle more complex constructors
    • getUnused

      public ArrayDeque<T> getUnused()
      Returns the stack containing all the unused instances.