C# Класс 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.
Показать файл Открыть проект

Открытые методы

Метод Описание
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.

Описание методов

Clear() публичный Метод

Clear the buffer and reset the total.
public Clear ( ) : void
Результат void

Dequeue() публичный Метод

Remove the oldest value from the back end of the buffer and return it.
public Dequeue ( ) : double
Результат double

DoubleCircularBufferWithStats() публичный Метод

Constructs a circular buffer with the specified capacity.
public DoubleCircularBufferWithStats ( int capacity ) : System
capacity int
Результат System

Enqueue() публичный Метод

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
Результат void

Pop() публичный Метод

Pop the most recently added value from the front end of the buffer and return it.
public Pop ( ) : double
Результат double