RingBuffer<T>
RingBuffer<T>
Properties
int capacity { get; }
The capacity of the buffer.
int count { get; }
The number of elements in the buffer.
bool isEmpty { get; }
True if the buffer is empty.
bool isFull { get; }
True if the buffer is full. Pushing onto the buffer will overwrite old elements.
T front { get; }
Returns the newest element in the buffer. This is equivalent to calling buffer[0].
T back { get; }
Returns the oldest element in the buffer. This is equivalent to calling buffer[buffer.count - 1].
T Item { get; set; }
T next { get; }
Returns the next front of the buffer. If the buffer is not full, this object has been allocated but is not considered "inside" the buffer. If the buffer is full, this returns the oldest element. The buffer is allocated during construction, so calling `buffer.Enqueue(buffer.next)` will advance the ring without allocating any new objects.
Methods
void Enqueue(T value)
Add an element to the front of the buffer. If the buffer is full, this overwrites the back of the buffer.
T Dequeue()
Remove the element at the back of the buffer.
T DequeueFront()
Remove the element at the front of the buffer.
void Clear()