Class CorrelationStack<T>

java.lang.Object
xal.tools.correlator.CorrelationStack<T>

public class CorrelationStack<T> extends Object
CorrelationStack is a correlator utility that uses a fixed sized, buffer to collect correlations from a correlator. An external object can then request all or the oldest correlations in which case the retrieved correlations are removed from the buffer. Hence the CorrelationStack is a LILO stack. CorrelationStack runs the correlator in "patient" mode (PatientBroadcaster), so the correlator posts mutually exclusive correlations each of which has passed the filter tests.
Author:
tap
  • Field Details

    • buffer

      protected final LinkedList<Correlation<T>> buffer
      buffer is a LILO stack of correlations with the oldest correlations having the smallest indices.
    • stackSize

      protected int stackSize
    • lastCorrelation

      protected Correlation<T> lastCorrelation
    • correlator

      protected Correlator<?,T,?> correlator
      Correlator
  • Constructor Details

    • CorrelationStack

      public CorrelationStack(Correlator<?,T,?> aCorrelator, int aStackSize)
      Creates a new instance of CorrelationStack
  • Method Details

    • getCorrelationCount

      public int getCorrelationCount()
      Get the number of correlations on the stack.
      Returns:
      The number of correlations on the stack.
    • isEmpty

      public boolean isEmpty()
      Determines whether there are any correlations left on the stack.
      Returns:
      true if there are no correlations on the stack and false otherwise.
    • clearBuffer

      public void clearBuffer()
      Empty all correlations from the buffer.
    • popCorrelation

      public Correlation<T> popCorrelation() throws NoSuchElementException
      Removes the oldest correlation in the buffer and returns it.
      Returns:
      The oldest correlation on the stack.
      Throws:
      NoSuchElementException - if there are no correlations on the stack.
    • popAllCorrelations

      public List<Correlation<T>> popAllCorrelations()
      Pop all correlations from the stack.
      Returns:
      all correlations on the stack.
    • push

      protected void push(Correlation<T> correlation)
      Push a correlation onto the stack.
      Parameters:
      correlation - The correlation to push onto the stack.
    • trimBuffer

      protected void trimBuffer()
      Trim the buffer down to the stackSize by removing the oldest correlations.