Package io.deephaven.base.ringbuffer
Interface RingBuffer
- All Known Implementing Classes:
ByteRingBuffer
,CharRingBuffer
,DoubleRingBuffer
,FloatRingBuffer
,IntRingBuffer
,LongRingBuffer
,ObjectRingBuffer
,ShortRingBuffer
public interface RingBuffer
Generic interface for a ring buffer and factory methods for buffer creation.
-
Method Summary
Modifier and TypeMethodDescriptionint
capacity()
Return how many items can fit in the buffer at its current capacity.void
clear()
Clear the buffer of all values.void
ensureRemaining
(int count) Ensure that at leastcount
free slots are available in the buffer.boolean
isEmpty()
Whether the buffer is entirely empty.boolean
isFull()
Whether the buffer is completely full.static <T> @NotNull RingBuffer
makeRingBuffer
(@NotNull Class<?> dataType, int capacity, boolean growable) int
Return how many free slots exist in this buffer at its current capacity.int
size()
Return how many items are currently in the buffer.
-
Method Details
-
makeRingBuffer
@NotNull static <T> @NotNull RingBuffer makeRingBuffer(@NotNull @NotNull Class<?> dataType, int capacity, boolean growable) -
isFull
boolean isFull()Whether the buffer is completely full. -
isEmpty
boolean isEmpty()Whether the buffer is entirely empty. -
size
int size()Return how many items are currently in the buffer. -
capacity
int capacity()Return how many items can fit in the buffer at its current capacity. If the buffer can grow, this number can change. -
remaining
int remaining()Return how many free slots exist in this buffer at its current capacity. -
clear
void clear()Clear the buffer of all values. If this is an object ring buffer, this will additionally set all values tonull
. -
ensureRemaining
void ensureRemaining(int count) Ensure that at leastcount
free slots are available in the buffer. If the buffer is growable, the capacity may be increased to accommodate the new slots. If the buffer is not growable and there are insufficient free slots, anUnsupportedOperationException
will be thrown.- Parameters:
count
- the number of free slots to ensure are available- Throws:
UnsupportedOperationException
- if the buffer is not growable and there are insufficient free slots
-