Interface RingBuffer<T>
- Type Parameters:
T
- the type of elements stored in the buffer.
- All Superinterfaces:
Iterable<T>
- All Known Implementing Classes:
OverwritingRingBuffer
A ring buffer abstraction
-
Method Summary
Modifier and TypeMethodDescriptionint
capacity()
Returns the total capacity of the buffer.dequeue()
Dequeues and returns the oldest item from the buffer.boolean
Enqueues the specified item into the buffer.boolean
isEmpty()
True if buffer is empty.int
size()
Returns the number of elements currently stored in the buffer.stream()
Returns a sequentialStream
of items in the buffer.Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
Method Details
-
isEmpty
boolean isEmpty()True if buffer is empty.- Returns:
- true if buffer is empty
-
size
int size()Returns the number of elements currently stored in the buffer.- Returns:
- the number of elements in the buffer.
-
capacity
int capacity()Returns the total capacity of the buffer.- Returns:
- the capacity of the buffer.
-
enqueue
Enqueues the specified item into the buffer.- Parameters:
item
- the item to be enqueued.- Returns:
true
if item is successfully enqueued.
-
dequeue
T dequeue()Dequeues and returns the oldest item from the buffer.- Returns:
- the oldest item in the buffer.
-
stream
Returns a sequentialStream
of items in the buffer.- Returns:
- a sequential stream of items in the buffer.
-