ELEMENTTYPE - The elements contained in the ring buffer.@NotThreadSafe public class RingBufferFifo<ELEMENTTYPE> extends Object
| Constructor and Description |
|---|
RingBufferFifo(int nCapacity,
boolean bAllowOverwrite)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
int |
getAvailable() |
int |
getCapacity() |
int |
getRemainingCapacity() |
boolean |
isOverwriteAllowed() |
com.helger.commons.state.EChange |
put(ELEMENTTYPE aElement)
Add a new element into the ring buffer
|
void |
reset()
Reset the buffer so that it is empty again.
|
ELEMENTTYPE |
take()
Take an element from the ring buffer.
|
String |
toString() |
public RingBufferFifo(@Nonnegative int nCapacity, boolean bAllowOverwrite)
nCapacity - The number of elements in the ring buffer. Must be > 0.bAllowOverwrite - true if the oldest element gets overwritten when the
next element is put.public void reset()
@Nonnegative public int getCapacity()
@Nonnegative public int getAvailable()
@Nonnegative public int getRemainingCapacity()
public boolean isOverwriteAllowed()
true if overwriting the oldest element is allowed (as
specified in the constructor).@Nonnull public com.helger.commons.state.EChange put(@Nullable ELEMENTTYPE aElement)
aElement - The element to be added. May be null.EChange.CHANGED if the element was successfully added or if
allow overwrite is active and the element was overwritten.@Nullable public ELEMENTTYPE take()
null if no more element is available or if the current
element is null.Copyright © 2017–2020 Philip Helger. All rights reserved.