Class CyclicBuffer<T>
java.lang.Object
org.apache.logging.log4j.core.util.CyclicBuffer<T>
- Type Parameters:
T
- The type of object stored in the buffer.
A bounded buffer containing elements of type T. When the number of elements to be added will exceed the
size of the buffer the oldest element will be overwritten. Access to the buffer is thread safe.
-
Constructor Summary
ConstructorDescriptionCyclicBuffer
(Class<T> clazz, int size) Instantiates a new CyclicBuffer of at mostmaxSize
events. -
Method Summary
-
Constructor Details
-
CyclicBuffer
Instantiates a new CyclicBuffer of at mostmaxSize
events.- Parameters:
clazz
- The Class associate with the type of object in the buffer.size
- The number of items in the buffer.- Throws:
IllegalArgumentException
- if the size is negative.
-
-
Method Details
-
add
Adds an item as the last event in the buffer.- Parameters:
item
- The item to add to the buffer.
-
removeAll
Removes all the elements from the buffer and returns them.- Returns:
- An array of the elements in the buffer.
-
isEmpty
public boolean isEmpty()Determines if the buffer contains elements.- Returns:
- true if the buffer is empty, false otherwise.
-