Struct simple_moving_average::SingleSumSMA[][src]

pub struct SingleSumSMA<Sample, Divisor, const WINDOW_SIZE: usize> { /* fields omitted */ }
Expand description

An SMA implementation that caches the sum of all samples currently in the sample window as a single value.

Implementations

Constructs a new SingleSumSMA with window size WINDOW_SIZE. This constructor is only available for Sample types that implement num_traits::Zero. If the Sample type does not, use the from_zero constructor instead.

Note that the Divisor type usually cannot be derived by the compiler when using this constructor and must be explicitly stated, even if it is the same as the Sample type.

Constructs a new SingleSumSMA with window size WINDOW_SIZE from the given zero sample. If the Sample type implements num_traits::Zero, the new constructor might be preferable to this.

Trait Implementations

Adds a sample to the series of samples. If the sample window is full, this will cause the oldest sample to be dropped, i.e. no longer contribute to the average. Read more

Returns the simple moving average value of all the samples in the sample window.

Returns the most recently added sample, if any.

Returns the total number of samples currently in the in the sample window. This value never exceeds the sample window size. Read more

Returns the maximum number of samples that fit in the sample window.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.