Skip to content

Commit

Permalink
use built in function
Browse files Browse the repository at this point in the history
  • Loading branch information
Topvennie committed Mar 29, 2024
1 parent f6aab9f commit f71ad1b
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions src/main/java/telraam/logic/positioner/CircularQueue.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,17 @@
public class CircularQueue<T> extends LinkedList<T> {

private final int maxSize;
private int size = 0;

public CircularQueue(int maxSize) {
this.maxSize = maxSize;
}

@Override
public boolean add(T e) {
if (this.size >= this.maxSize) {
if (size() >= this.maxSize) {
removeFirst();
this.size--;
}

boolean result = super.add(e);

if (result) {
this.size++;
}

return result;
return super.add(e);
}

}

0 comments on commit f71ad1b

Please sign in to comment.