Class ArrayPool<T>

java.lang.Object
net.dermetfan.gdx.utils.ArrayPool<T>
Direct Known Subclasses:
ReflectionArrayPool

public abstract class ArrayPool<T>
extends java.lang.Object
pools arrays by their size
Since:
0.11.1
  • Field Summary

    Fields
    Modifier and Type Field Description
    int max
    the maximum amount of arrays of different lengths that will be pooled
    int maxEach
    the maximum amount of arrays of the same length that will be pooled
  • Constructor Summary

    Constructors
    Constructor Description
    ArrayPool​(int max, int maxEach)  
  • Method Summary

    Modifier and Type Method Description
    void clear()  
    void free​(T[] array)  
    int getFree​(int length)  
    protected abstract T[] newArray​(int length)  
    T[] obtain​(int length)  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • max

      public final int max
      the maximum amount of arrays of different lengths that will be pooled
    • maxEach

      public final int maxEach
      the maximum amount of arrays of the same length that will be pooled
  • Constructor Details

    • ArrayPool

      public ArrayPool​(int max, int maxEach)
  • Method Details

    • newArray

      protected abstract T[] newArray​(int length)
      Returns:
      a new array of the given length
    • obtain

      public T[] obtain​(int length)
      Parameters:
      length - the desired length of the array
    • free

      public void free​(T[] array)
      Parameters:
      array - the array to put back into the pool
    • clear

      public void clear()
    • getFree

      public int getFree​(int length)
      Returns:
      the number of arrays of the given length in the pool