Class CyclicBuffer<E>

java.lang.Object
ch.qos.logback.core.helpers.CyclicBuffer<E>

public class CyclicBuffer<E> extends Object
CyclicBuffer holds values in a cyclic array.

It allows read access to any element in the buffer not just the first or last element.

Author:
Ceki Gülcü
  • Constructor Details

  • Method Details

    • clear

      public void clear()
      Clears the buffer and resets all attributes.
    • add

      public void add(E event)
      Add an event as the last event in the buffer.
    • get

      public E get(int i)
      Get the ith oldest event currently in the buffer. If i is outside the range 0 to the number of elements currently in the buffer, then null is returned.
    • getMaxSize

      public int getMaxSize()
    • get

      public E get()
      Get the oldest (first) element in the buffer. The oldest element is removed from the buffer.
    • asList

      public List<E> asList()
    • length

      public int length()
      Get the number of elements in the buffer. This number is guaranteed to be in the range 0 to maxSize (inclusive).
    • resize

      public void resize(int newSize)
      Resize the cyclic buffer to newSize.
      Throws:
      IllegalArgumentException - if newSize is negative.