Revert "totalngram: use CircularFifoQueue as sliding window base"
Seems to be a lot slower than with LinkedList, strange.
This reverts commit 73203b7c8a57731fdb7e76dce90034df7ffb88d8.
diff --git a/pom.xml b/pom.xml
index 308e1c2..97ca101 100644
--- a/pom.xml
+++ b/pom.xml
@@ -150,11 +150,5 @@
<artifactId>etaprinter</artifactId>
<version>2.0.0</version>
</dependency>
- <!-- https://mvnrepository.com/artifact/org.apache.commons/commons-collections4 -->
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-collections4</artifactId>
- <version>4.1</version>
- </dependency>
</dependencies>
</project>
\ No newline at end of file
diff --git a/src/main/java/org/ids_mannheim/SlidingWindowQueue.java b/src/main/java/org/ids_mannheim/SlidingWindowQueue.java
index cf3db43..4f07362 100644
--- a/src/main/java/org/ids_mannheim/SlidingWindowQueue.java
+++ b/src/main/java/org/ids_mannheim/SlidingWindowQueue.java
@@ -1,22 +1,22 @@
package org.ids_mannheim;
+import java.util.LinkedList;
import java.util.function.Consumer;
-import org.apache.commons.collections4.queue.CircularFifoQueue;
-public class SlidingWindowQueue extends CircularFifoQueue {
+public class SlidingWindowQueue extends LinkedList {
private final int maxSize;
private final Consumer<String> flush;
public SlidingWindowQueue(int size, Consumer<String> flush) {
- super(size);
this.maxSize = size;
this.flush = flush;
}
public boolean add(String k) {
boolean r = super.add(k);
- if (isAtFullCapacity()) {
+ if (size() == maxSize) {
this.flush.accept(String.join(" ", this));
+ remove(0);
}
return r;
}