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>

public class SlidingWindow<T> extends LinkedList<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:
  • 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

      public boolean add(T object)
      Adds a new object to the sliding window. If the window reaches its maximum size, the oldest element is removed.
      Specified by:
      add in interface Collection<T>
      Specified by:
      add in interface Deque<T>
      Specified by:
      add in interface List<T>
      Specified by:
      add in interface Queue<T>
      Overrides:
      add in class LinkedList<T>
      Parameters:
      object - object to be added to the window
      Returns:
      true if the object is added, false otherwise