Module VirtualizedFX
Class CellsQueue<T,C extends Cell<T>>
java.lang.Object
java.util.AbstractCollection<C>
java.util.AbstractList<C>
java.util.AbstractSequentialList<C>
java.util.LinkedList<C>
io.github.palexdev.virtualizedfx.utils.CellsQueue<T,C>
- All Implemented Interfaces:
Serializable
,Cloneable
,Iterable<C>
,Collection<C>
,Deque<C>
,List<C>
,Queue<C>
,SequencedCollection<C>
A special kind of
LinkedList
which discards the oldest added item once it reaches the set capacity.
Basically the same as CircularQueue
, but automatically invokes Cell.dispose()
on cell that are discarded.
- See Also:
-
Field Summary
Fields inherited from class java.util.AbstractList
modCount
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
boolean
addAll
(Collection<? extends C> cells) int
boolean
Adds the given cell to the queue.void
setCapacity
(int capacity) Sets the queue's capacity.Methods inherited from class java.util.LinkedList
add, 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, reversed, set, size, spliterator, toArray, toArray
Methods inherited from class java.util.AbstractSequentialList
iterator
Methods inherited from class java.util.AbstractList
equals, hashCode, listIterator, removeRange, subList
Methods inherited from class java.util.AbstractCollection
containsAll, isEmpty, removeAll, retainAll, toString
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods inherited from interface java.util.List
containsAll, equals, hashCode, isEmpty, iterator, listIterator, removeAll, replaceAll, retainAll, sort, subList
-
Constructor Details
-
CellsQueue
public CellsQueue(int capacity)
-
-
Method Details
-
queue
Adds the given cell to the queue. If at capacity, the oldest cell is disposed and discarded.- Returns:
- whether the cell was added
-
getCapacity
public int getCapacity()- Returns:
- the queue's capacity, the maximum number of cells that can be added
-
setCapacity
public void setCapacity(int capacity) Sets the queue's capacity. If the parameter is 0, every cell is disposed and removed. If the new capacity is lesser than the current one, then the oldest cell is removed until the capacity is reached. -
add
-
addAll
-