Class WindowSeriesStore

java.lang.Object
com.wualabs.qtsurfer.engine.core.state.WindowSeriesStore
All Implemented Interfaces:
WindowSeries, WritableWindowSeries, Iterable<Double>
Direct Known Subclasses:
MovingAverage

public class WindowSeriesStore extends Object implements WritableWindowSeries
Stores n periods of past data. Default implementation of a WritableWindowSeries
  • Constructor Details

    • WindowSeriesStore

      public WindowSeriesStore(int windowSize)
  • Method Details

    • add

      public void add(double value)
      Adds a value to the rolling window. When the window exceeds its configured size, the oldest value is removed and passed to onRollingWindow(double) for cleanup (e.g., subtracting from a running sum).
      Specified by:
      add in interface WritableWindowSeries
      Parameters:
      value - the value to add to the window
    • getValue

      public double getValue(int index)
      Specified by:
      getValue in interface WindowSeries
    • size

      public int size()
      Specified by:
      size in interface WindowSeries
    • isEmpty

      public boolean isEmpty()
    • clear

      public void clear()
      Specified by:
      clear in interface WritableWindowSeries
    • iterator

      public Iterator<Double> iterator()
      Specified by:
      iterator in interface Iterable<Double>
    • onRollingWindow

      protected void onRollingWindow(double firstValue)
      Call back with discarded first value from buffer;
      Parameters:
      firstValue -
    • getWindowSize

      public int getWindowSize()
      Specified by:
      getWindowSize in interface WindowSeries