Interface RingBuffer<T>

Type Parameters:
T - the type of elements stored in the buffer.
All Superinterfaces:
Iterable<T>
All Known Implementing Classes:
OverwritingRingBuffer

public interface RingBuffer<T> extends Iterable<T>
A ring buffer abstraction
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Returns the total capacity of the buffer.
    Dequeues and returns the oldest item from the buffer.
    boolean
    enqueue(T item)
    Enqueues the specified item into the buffer.
    boolean
    True if buffer is empty.
    int
    Returns the number of elements currently stored in the buffer.
    Returns a sequential Stream 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

      boolean enqueue(T item)
      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

      Stream<T> stream()
      Returns a sequential Stream of items in the buffer.
      Returns:
      a sequential stream of items in the buffer.