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
ConstructorDescriptionSlidingWindow
(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, 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
-
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:
add
in interfaceCollection<T>
- Specified by:
add
in interfaceDeque<T>
- Specified by:
add
in interfaceList<T>
- Specified by:
add
in interfaceQueue<T>
- Overrides:
add
in classLinkedList<T>
- Parameters:
object
- object to be added to the window- Returns:
true
if the object is added,false
otherwise
-