Class CircularBuffer<T>
Fixed-size circular buffer to prevent unbounded memory growth
public class CircularBuffer<T>
Type Parameters
T
- Inheritance
-
objectCircularBuffer<T>
Constructors
CircularBuffer(int)
public CircularBuffer(int capacity)
Parameters
capacityint
Properties
Capacity
public int Capacity { get; }
Property Value
- int
Count
public int Count { get; }
Property Value
- int
Items
public IReadOnlyList<T> Items { get; }
Property Value
- IReadOnlyList<T>
Methods
Add(T)
public void Add(T item)
Parameters
itemT
Clear()
public void Clear()
Get(int)
Get item at logical index (0 = oldest, Count-1 = newest). Zero-allocation.
public T Get(int index)
Parameters
indexint
Returns
- T