Class Window
A rolling window of the most recent readings, with the stats over them.
public sealed class Window : IDisposable
- Inheritance
-
Window
- Implements
- Inherited Members
Remarks
The core helpers are generic over their capacity, which cannot cross the C ABI, so these are built with room for WindowCapacity readings and keep fewer when asked. A reading that is not a finite number is not kept.
Constructors
Window(int)
Creates an empty window.
public Window(int capacity = 32)
Parameters
capacityintHow many readings to keep, from 1 to 32; 32 unless told fewer.
Exceptions
- ArgumentOutOfRangeException
capacityis not from 1 to 32.
Properties
Capacity
How many readings it holds before it starts dropping the oldest.
public int Capacity { get; }
Property Value
Count
How many readings the window holds.
public int Count { get; }
Property Value
IsFull
Whether the window holds as many readings as it keeps.
public bool IsFull { get; }
Property Value
Methods
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
Latest()
The most recent reading, or null while the window is empty.
public float? Latest()
Returns
- float?
The latest reading, if there is one.
Max()
The largest reading, or null while the window is empty.
public float? Max()
Returns
- float?
The maximum, if there is one.
Mean()
The mean of the readings, or null while the window is empty.
public float? Mean()
Returns
- float?
The mean, if there is one.
Min()
The smallest reading, or null while the window is empty.
public float? Min()
Returns
- float?
The minimum, if there is one.
Oldest()
The oldest reading still held, or null while the window is empty.
public float? Oldest()
Returns
- float?
The oldest reading, if there is one.
Push(float)
Adds a reading, dropping the oldest once the window is full.
public void Push(float reading)
Parameters
readingfloatThe reading to add. One that is not a finite number is not kept.
Range()
The spread between the smallest and largest readings, or null while empty.
public float? Range()
Returns
- float?
The range, if there is one.
Variance()
The population variance of the readings, 0 for one reading, or null while empty.
public float? Variance()
Returns
- float?
The variance, if there is one.