Class RingBuffer


  • public class RingBuffer
    extends java.lang.Object
    Ring buffer for gathering (entropy) data indefinitely, discarding the oldest data to limit memory usage.
    • Constructor Summary

      Constructors 
      Constructor Description
      RingBuffer​(int bytes)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clear()
      Clear ring buffer data.
      Data get()
      Get entire ring buffer as data.
      byte get​(int index)
      Get byte at index of ring buffer.
      Data hash()
      Cryptographic hash (SHA256) of ring buffer data.
      byte pop()  
      Data pop​(int bytes)  
      void push​(byte value)
      Append byte to end of ring buffer.
      void push​(long value)
      Append long value to end of ring buffer as 8 bytes.
      void push​(Data data)
      Append bytes to end of ring buffer.
      int size()
      Number of bytes in the ring buffer.
      • Methods inherited from class java.lang.Object

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

      • RingBuffer

        public RingBuffer​(int bytes)
    • Method Detail

      • push

        public void push​(byte value)
        Append byte to end of ring buffer.
        Parameters:
        value -
      • push

        public void push​(long value)
        Append long value to end of ring buffer as 8 bytes.
        Parameters:
        value -
      • push

        public void push​(@NonNull
                         Data data)
        Append bytes to end of ring buffer.
        Parameters:
        data -
      • size

        public int size()
        Number of bytes in the ring buffer.
        Returns:
      • get

        public byte get​(int index)
        Get byte at index of ring buffer.
        Parameters:
        index -
        Returns:
      • pop

        public byte pop()
      • pop

        @NonNull
        public Data pop​(int bytes)
      • clear

        public void clear()
        Clear ring buffer data.
      • get

        @NonNull
        public Data get()
        Get entire ring buffer as data.
        Returns:
      • hash

        @Nullable
        public Data hash()
        Cryptographic hash (SHA256) of ring buffer data.
        Returns:
        SHA256 hash, or null if buffer is empty or SHA256 is not available