diff --git a/modules/common/src/main/java/edu/tigers/sumatra/data/TimeLimitedBuffer.java b/modules/common/src/main/java/edu/tigers/sumatra/data/TimeLimitedBuffer.java index bb83d0cc..6290e4eb 100644 --- a/modules/common/src/main/java/edu/tigers/sumatra/data/TimeLimitedBuffer.java +++ b/modules/common/src/main/java/edu/tigers/sumatra/data/TimeLimitedBuffer.java @@ -73,7 +73,7 @@ private void reduceBySize() } while (data.size() > maxElements) { - data.remove(0); + data.removeFirst(); } } @@ -85,11 +85,11 @@ private void reduceByDuration() // no duration limit return; } - long maxTimestamp = data.get(data.size() - 1).timestamp; + long maxTimestamp = data.getLast().timestamp; long minTimestamp = maxTimestamp - (long) (maxDuration * 1e9); - while (!data.isEmpty() && data.get(0).timestamp < minTimestamp) + while (!data.isEmpty() && data.getFirst().timestamp < minTimestamp) { - data.remove(0); + data.removeFirst(); } } @@ -105,9 +105,9 @@ public void reduceByAbsoluteDuration(long currentTimestamp) // no duration limit return; } - while (!data.isEmpty() && data.get(0).timestamp < currentTimestamp - (long) (maxDuration * 1e9)) + while (!data.isEmpty() && data.getFirst().timestamp < currentTimestamp - (long) (maxDuration * 1e9)) { - data.remove(0); + data.removeFirst(); } }