Module es.upm.fi.cig.multictbnc
Class SlidingWindow<T>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<E>
java.util.AbstractSequentialList<E>
java.util.LinkedList<T>
es.upm.fi.cig.multictbnc.data.representation.SlidingWindow<T>
- Type Parameters:
T- the type of elements held in this sliding window
- All Implemented Interfaces:
Serializable,Cloneable,Iterable<T>,Collection<T>,Deque<T>,List<T>,Queue<T>
Represents a sliding window data structure. It is a fixed-size window that slides over a sequence of elements,
typically used for processing streams of data. The window adds new elements to the end and removes the oldest
elements to maintain a constant size.
- See Also:
-
Field Summary
Fields inherited from class java.util.AbstractList
modCount -
Constructor Summary
ConstructorsConstructorDescriptionSlidingWindow(int size) Constructs a sliding window with the specified size. -
Method Summary
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
-
SlidingWindow
public SlidingWindow(int size) Constructs a sliding window with the specified size.- Parameters:
size- fixed size of the sliding window
-
-
Method Details
-
add
Adds a new object to the sliding window. If the window reaches its maximum size, the oldest element is removed.- Specified by:
addin interfaceCollection<T>- Specified by:
addin interfaceDeque<T>- Specified by:
addin interfaceList<T>- Specified by:
addin interfaceQueue<T>- Overrides:
addin classLinkedList<T>- Parameters:
object- object to be added to the window- Returns:
trueif the object is added,falseotherwise
-