Skip to main content
Version: Normcore 2

RingBuffer<T>

RingBuffer<T>

Properties

capacity

int capacity { get; }

The capacity of the buffer.

count

int count { get; }

The number of elements in the buffer.

isEmpty

bool isEmpty { get; }

True if the buffer is empty.

isFull

bool isFull { get; }

True if the buffer is full. Pushing onto the buffer will overwrite old elements.

front

T front { get; }

Returns the newest element in the buffer. This is equivalent to calling buffer[0].

back

T back { get; }

Returns the oldest element in the buffer. This is equivalent to calling buffer[buffer.count - 1].

Item

T Item { get; set; }

next

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

Enqueue

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.

Dequeue

T Dequeue()

Remove the element at the back of the buffer.

DequeueFront

T DequeueFront()

Remove the element at the front of the buffer.

Clear

void Clear()