java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<E>
java.util.AbstractSequentialList<E>
java.util.LinkedList<E>
io.github.palexdev.materialfx.collections.CircularQueue<E>
- All Implemented Interfaces:
Serializable,Cloneable,Iterable<E>,Collection<E>,Deque<E>,List<E>,Queue<E>
This is the implementation of a circular FIFO queue.
When the maximum size is reached the oldest element is removed and replaced
by the new one.
- See Also:
-
Field Summary
Fields inherited from class java.util.AbstractList
modCount -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanAdds the specified element to the queue and if it is full removes the oldest element and then adds the new one.voidsetSize(int size) Sets the maximum size of the queue and removes exceeding elements if the specified size is lesser than the number of elements.Methods inherited from class java.util.LinkedList
add, addAll, addAll, addFirst, addLast, clear, clone, contains, descendingIterator, element, get, getFirst, getLast, indexOf, lastIndexOf, listIterator, offer, offerFirst, offerLast, peek, peekFirst, peekLast, poll, pollFirst, pollLast, pop, push, remove, remove, remove, removeFirst, removeFirstOccurrence, removeLast, removeLastOccurrence, set, size, spliterator, toArray, toArrayMethods inherited from class java.util.AbstractSequentialList
iteratorMethods inherited from class java.util.AbstractList
equals, hashCode, listIterator, removeRange, subListMethods inherited from class java.util.AbstractCollection
containsAll, isEmpty, removeAll, retainAll, toStringMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.List
containsAll, equals, hashCode, isEmpty, iterator, listIterator, removeAll, replaceAll, retainAll, sort, subList
-
Constructor Details
-
CircularQueue
public CircularQueue(int size)
-
-
Method Details
-
setSize
public void setSize(int size) Sets the maximum size of the queue and removes exceeding elements if the specified size is lesser than the number of elements.- Parameters:
size- The new desired size- Throws:
IllegalArgumentException- if the desired size is 0
-
add
Adds the specified element to the queue and if it is full removes the oldest element and then adds the new one.
-