Table of Contents

Class CircularBuffer<T>

Namespace
Backdash.Data
Assembly
Backdash.dll

A collection data structure that uses a single fixed-size buffer as if it were connected end-to-end.

public sealed class CircularBuffer<T> : IReadOnlyList<T>, IReadOnlyCollection<T>, IEnumerable<T>, IEnumerable, IEquatable<CircularBuffer<T>>

Type Parameters

T
Inheritance
CircularBuffer<T>
Implements
Inherited Members

Constructors

CircularBuffer(int)

A collection data structure that uses a single fixed-size buffer as if it were connected end-to-end.

public CircularBuffer(int capacity)

Parameters

capacity int

Properties

Capacity

public int Capacity { get; }

Property Value

int

CurrentIndex

public int CurrentIndex { get; }

Property Value

int

IsEmpty

public bool IsEmpty { get; }

Property Value

bool

IsFull

public bool IsFull { get; }

Property Value

bool

this[Index]

public ref T this[Index index] { get; }

Parameters

index Index

Property Value

T

this[int]

public ref T this[int index] { get; }

Parameters

index int

Property Value

T

LastIndex

public int LastIndex { get; }

Property Value

int

Size

public int Size { get; }

Property Value

int

Methods

Add(in T)

public void Add(in T item)

Parameters

item T

AddRange(ReadOnlySpan<T>)

public void AddRange(ReadOnlySpan<T> values)

Parameters

values ReadOnlySpan<T>

Advance(int)

public void Advance(int offset = 1)

Parameters

offset int

At(int)

public ref T At(int index)

Parameters

index int

Returns

T

Back()

public ref T Back()

Returns

T

Clear(bool)

public void Clear(bool clearArray = false)

Parameters

clearArray bool

CopyFrom(ReadOnlySpan<T>)

public void CopyFrom(ReadOnlySpan<T> values)

Parameters

values ReadOnlySpan<T>

CopyTo(Span<T>)

public void CopyTo(Span<T> destination)

Parameters

destination Span<T>

Discard(int)

public void Discard(int offset = 1)

Parameters

offset int

Drop()

public T Drop()

Returns

T

Equals(CircularBuffer<T>?)

public bool Equals(CircularBuffer<T>? other)

Parameters

other CircularBuffer<T>

Returns

bool

Equals(CircularBuffer<T>?, EqualityComparer<T>)

public bool Equals(CircularBuffer<T>? other, EqualityComparer<T> comparer)

Parameters

other CircularBuffer<T>
comparer EqualityComparer<T>

Returns

bool

Equals(object?)

public override bool Equals(object? obj)

Parameters

obj object

Returns

bool

Fill(T)

public void Fill(T value)

Parameters

value T

FillWith(Func<T>)

public void FillWith(Func<T> valueFn)

Parameters

valueFn Func<T>

Front()

public ref T Front()

Returns

T

GetEnumerator()

public CircularBuffer<T>.Enumerator GetEnumerator()

Returns

CircularBuffer<T>.Enumerator

GetHashCode()

public override int GetHashCode()

Returns

int

GetResetSpan(int, bool)

public Span<T> GetResetSpan(int size, bool clearArray = false)

Parameters

size int
clearArray bool

Returns

Span<T>

GetSpan(out ReadOnlySpan<T>, out ReadOnlySpan<T>)

public int GetSpan(out ReadOnlySpan<T> begin, out ReadOnlySpan<T> end)

Parameters

begin ReadOnlySpan<T>
end ReadOnlySpan<T>

Returns

int

Next()

public ref T Next()

Returns

T

ToArray()

public T[] ToArray()

Returns

T[]

ToString()

public override string ToString()

Returns

string

TryDrop(out T?)

public bool TryDrop(out T? item)

Parameters

item T

Returns

bool

Operators

operator ==(in CircularBuffer<T>, in CircularBuffer<T>)

public static bool operator ==(in CircularBuffer<T> a, in CircularBuffer<T> b)

Parameters

a CircularBuffer<T>
b CircularBuffer<T>

Returns

bool

operator !=(CircularBuffer<T>, CircularBuffer<T>)

public static bool operator !=(CircularBuffer<T> a, CircularBuffer<T> b)

Parameters

a CircularBuffer<T>
b CircularBuffer<T>

Returns

bool