Package com.polytechnik.utils
Class CircularList<T extends CircularList.TimeAccess>
java.lang.Object
com.polytechnik.utils.CircularList<T>
A circular buffer to store data.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
static interface
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
boolean
backwardForEachEntry
(Predicate<T> procedure, int n_skip_from_the_end) The method loops backward over the elements of the list, set the n_skip_from_the_end=0 to loop over all elements.int
clearBefore
(long t0, Predicate<T> callback) int
clearBefore
(long t0, Predicate<T> callback, int min_elements_to_keep) Clear all elements with time <t0.int
void
ensureCapacity
(int newcapacity) boolean
forwardForEachEntry
(Predicate<T> procedure, int n_elements_to_scan) The method loops forward over the elements of the list, set the n_elements_to_scan=getSize(), to loop over all elements.long
int
getSize()
static void
int
removeBrokenElement
(Predicate<T> checker) Remove element.
-
Field Details
-
buffer
-
ptr
private int ptr -
n_elements
private int n_elements -
last_cleared_before
private long last_cleared_before
-
-
Constructor Details
-
CircularList
public CircularList(int initialcapacity) -
CircularList
public CircularList()
-
-
Method Details
-
ensureCapacity
public void ensureCapacity(int newcapacity) -
add
-
clearBefore
-
clearBefore
-
removeBrokenElement
-
copyData
-
getLastClearedBefore
public long getLastClearedBefore() -
getSize
public int getSize() -
getLastAddedElement
-
backwardForEachEntry
-
forwardForEachEntry
-
main
-