C# Class Redzen.Structures.DoubleCircularBufferWithStats

This is a circular buffer of double precision floating point numbers. A circular buffer must be assigned a capacity at construction time. Values can be enqueued indefintely, but when the buffer's capacity is reached the oldest values in it are overwritten, thus the buffer is best thought of as a circular array or buffer. In addition to normal circular buffer behaviour this class has a 'total' variable that maintains the sum total of all values currently in the buffer. Therefore when the buffer reaches capacity and new values overwrite old ones the total is reduced by the value being overwritten and increased by the new value. This allows us to cheaply (in computational terms) maintain a sum total and mean for all values in the buffer. Note that this class isn't made generic because of the lack of operator contraints required to maintain the sum total of contained items. At time of writing there were ways around this limitation but they either had performance implications and/or resulted in ugly code.
Afficher le fichier Open project: colgreen/Redzen

Méthodes publiques

Méthode Description
Clear ( ) : void

Clear the buffer and reset the total.

Dequeue ( ) : double

Remove the oldest value from the back end of the buffer and return it.

DoubleCircularBufferWithStats ( int capacity ) : System

Constructs a circular buffer with the specified capacity.

Enqueue ( double item ) : void

Enqueue a new value. This overwrites the oldest value in the buffer if the buffer has reached capacity.

Pop ( ) : double

Pop the most recently added value from the front end of the buffer and return it.

Method Details

Clear() public méthode

Clear the buffer and reset the total.
public Clear ( ) : void
Résultat void

Dequeue() public méthode

Remove the oldest value from the back end of the buffer and return it.
public Dequeue ( ) : double
Résultat double

DoubleCircularBufferWithStats() public méthode

Constructs a circular buffer with the specified capacity.
public DoubleCircularBufferWithStats ( int capacity ) : System
capacity int
Résultat System

Enqueue() public méthode

Enqueue a new value. This overwrites the oldest value in the buffer if the buffer has reached capacity.
public Enqueue ( double item ) : void
item double
Résultat void

Pop() public méthode

Pop the most recently added value from the front end of the buffer and return it.
public Pop ( ) : double
Résultat double