Class RingBuffer
- java.lang.Object
-
- io.heraldprox.herald.sensor.datatype.random.RingBuffer
-
public class RingBuffer extends java.lang.ObjectRing 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 voidclear()Clear ring buffer data.Dataget()Get entire ring buffer as data.byteget(int index)Get byte at index of ring buffer.Datahash()Cryptographic hash (SHA256) of ring buffer data.bytepop()Datapop(int bytes)voidpush(byte value)Append byte to end of ring buffer.voidpush(long value)Append long value to end of ring buffer as 8 bytes.voidpush(Data data)Append bytes to end of ring buffer.intsize()Number of bytes in the ring buffer.
-
-
-
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
-
-