Table of Contents

Class RingBuffer<T>

Namespace
AlgorithmsSW.Buffer
Assembly
AlgorithmsSW.dll

An implementation of IBuffer<T> that uses a fixed-size array in a circular way.

[ExerciseReference(1, 3, 39)]
public sealed class RingBuffer<T> : IBuffer<T>, IEnumerable<T>, IEnumerable

Type Parameters

T
Inheritance
RingBuffer<T>
Implements
Inherited Members
Extension Methods

Constructors

RingBuffer(int)

public RingBuffer(int capacity)

Parameters

capacity int

Properties

Capacity

Gets the maximum number of elements the buffer can hold.

public int Capacity { get; }

Property Value

int

Count

Gets the current number of elements in the buffer.

public int Count { get; }

Property Value

int

First

Gets the first element in the buffer.

public T First { get; }

Property Value

T

IsFull

Gets a value indicating whether the buffer is full.

public bool IsFull { get; }

Property Value

bool

this[int]

Gets the element at the specified index, where 0 corresponds to the front of the buffer (that is, the oldest element).

public T this[int index] { get; }

Parameters

index int

Property Value

T

Last

Gets the last element in the buffer.

public T Last { get; }

Property Value

T

Methods

Clear()

Clears all items from the buffer.

public void Clear()

GetEnumerator()

Returns an enumerator that iterates through the collection.

public IEnumerator<T> GetEnumerator()

Returns

IEnumerator<T>

An enumerator that can be used to iterate through the collection.

Insert(T)

Inserts an item into the buffer.

public void Insert(T item)

Parameters

item T

The item to insert into the buffer.

ResetPointers()

public void ResetPointers()