Package xal.tools.correlator
Class CorrelationStack<T>
java.lang.Object
xal.tools.correlator.CorrelationStack<T>
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 Summary
FieldsModifier and TypeFieldDescriptionprotected final LinkedList<Correlation<T>>
buffer is a LILO stack of correlations with the oldest correlations having the smallest indices.protected Correlator<?,
T, ?> Correlatorprotected Correlation<T>
protected int
-
Constructor Summary
ConstructorsConstructorDescriptionCorrelationStack
(Correlator<?, T, ?> aCorrelator, int aStackSize) Creates a new instance of CorrelationStack -
Method Summary
Modifier and TypeMethodDescriptionvoid
Empty all correlations from the buffer.int
Get the number of correlations on the stack.boolean
isEmpty()
Determines whether there are any correlations left on the stack.List<Correlation<T>>
Pop all correlations from the stack.Removes the oldest correlation in the buffer and returns it.protected void
push
(Correlation<T> correlation) Push a correlation onto the stack.protected void
Trim the buffer down to the stackSize by removing the oldest correlations.
-
Field Details
-
buffer
buffer is a LILO stack of correlations with the oldest correlations having the smallest indices. -
stackSize
protected int stackSize -
lastCorrelation
-
correlator
Correlator
-
-
Constructor Details
-
CorrelationStack
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
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
Pop all correlations from the stack.- Returns:
- all correlations on the stack.
-
push
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.
-