java.lang.Object
ch.qos.logback.core.helpers.CyclicBuffer<E>
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 Summary
ConstructorDescriptionCyclicBuffer
(int maxSize) Instantiate a new CyclicBuffer of at mostmaxSize
events.CyclicBuffer
(CyclicBuffer<E> other) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add anevent
as the last event in the buffer.asList()
void
clear()
Clears the buffer and resets all attributes.get()
Get the oldest (first) element in the buffer.get
(int i) Get the ith oldest event currently in the buffer.int
int
length()
Get the number of elements in the buffer.void
resize
(int newSize) Resize the cyclic buffer tonewSize
.
-
Constructor Details
-
CyclicBuffer
Instantiate a new CyclicBuffer of at mostmaxSize
events. ThemaxSize
argument must a positive integer.- Parameters:
maxSize
- The maximum number of elements in the buffer.- Throws:
IllegalArgumentException
-
CyclicBuffer
-
-
Method Details
-
clear
Clears the buffer and resets all attributes. -
add
-
get
-
getMaxSize
-
get
-
asList
-
length
Get the number of elements in the buffer. This number is guaranteed to be in the range 0 tomaxSize
(inclusive). -
resize
Resize the cyclic buffer tonewSize
.- Throws:
IllegalArgumentException
- ifnewSize
is negative.
-