Class CircularBuffer<T>
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
-
IEnumerable<T>
- 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
CurrentIndex
public int CurrentIndex { get; }
Property Value
IsEmpty
public bool IsEmpty { get; }
Property Value
IsFull
public bool IsFull { get; }
Property Value
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
Size
public int Size { get; }
Property Value
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
Equals(CircularBuffer<T>?, EqualityComparer<T>)
public bool Equals(CircularBuffer<T>? other, EqualityComparer<T> comparer)
Parameters
other
CircularBuffer<T>comparer
EqualityComparer<T>
Returns
Equals(object?)
public override bool Equals(object? obj)
Parameters
obj
object
Returns
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
GetHashCode()
public override int GetHashCode()
Returns
GetResetSpan(int, bool)
public Span<T> GetResetSpan(int size, bool clearArray = false)
Parameters
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
Next()
public ref T Next()
Returns
- T
ToArray()
public T[] ToArray()
Returns
- T[]
ToString()
public override string ToString()
Returns
TryDrop(out T?)
public bool TryDrop(out T? item)
Parameters
item
T
Returns
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
operator !=(CircularBuffer<T>, CircularBuffer<T>)
public static bool operator !=(CircularBuffer<T> a, CircularBuffer<T> b)
Parameters
a
CircularBuffer<T>b
CircularBuffer<T>