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
ConstructorsConstructorDescriptionCyclicBuffer(int maxSize) Instantiate a new CyclicBuffer of at mostmaxSizeevents.CyclicBuffer(CyclicBuffer<E> other) -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd aneventas the last event in the buffer.asList()voidclear()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.intintlength()Get the number of elements in the buffer.voidresize(int newSize) Resize the cyclic buffer tonewSize.
-
Constructor Details
-
CyclicBuffer
Instantiate a new CyclicBuffer of at mostmaxSizeevents. ThemaxSizeargument 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- ifnewSizeis negative.
-