Class LevelBytePool

java.lang.Object
de.tomatengames.util.pool.LevelBytePool
All Implemented Interfaces:
BytePool

public class LevelBytePool extends Object implements BytePool
The LevelBytePool class provides a pool of byte arrays, allowing efficient management and reuse of byte arrays with varying lengths. It uses multiple LinkedPool instances to manage arrays of different sizes.
Since:
1.8
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a new LevelBytePool instance with pre-configured pools for byte arrays of different sizes.
  • Method Summary

    Modifier and Type
    Method
    Description
    Pooled<byte[]>
    claim(int minLength)
    Claims a byte array that is at least as long as the specified minimum length.
    void
    Cleans all pools by reducing their sizes to the minimum size recorded since the last clean operation.
    Pool<byte[]>
    ofLength(int minLength)
    Returns a pool that provides byte arrays that are at least as long as the specified minimum length.

    Methods inherited from class Object

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

    • LevelBytePool

      public LevelBytePool()
      Constructs a new LevelBytePool instance with pre-configured pools for byte arrays of different sizes.
  • Method Details

    • clean

      public void clean()
      Cleans all pools by reducing their sizes to the minimum size recorded since the last clean operation.

      Call this regularly for active cleaning.

    • ofLength

      public Pool<byte[]> ofLength(int minLength)
      Description copied from interface: BytePool
      Returns a pool that provides byte arrays that are at least as long as the specified minimum length.
      Specified by:
      ofLength in interface BytePool
      Parameters:
      minLength - The minimum required length of the byte arrays.
      Returns:
      A Pool instance for byte arrays of at least the specified minimum length.
    • claim

      public Pooled<byte[]> claim(int minLength)
      Description copied from interface: BytePool
      Claims a byte array that is at least as long as the specified minimum length.
      Specified by:
      claim in interface BytePool
      Parameters:
      minLength - The minimum required length of the byte array.
      Returns:
      A Pooled instance wrapping a byte array of at least the specified minimum length.