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.
파일 보기 프로젝트 열기: colgreen/Redzen

공개 메소드들

메소드 설명
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