CircularArray<T>

public class CircularArray<T> : IEnumerable<T>
Represents a threadsafe circular array. A circular array has a maximum length, but items can always be added to it efficiently. Once the capacity has been reached, newly added items override the oldest items.
TArray type.

Constructors

CircularArray

#
Create a new circular array.
public CircularArray(
capacity
Maximum capacity.
)

Properties

Capacity

#
Gets the maximum capacity of this array.
public int Capacity { get; }

Count

#
Gets the number of items stored in the array.
public int Count { get; }

ItemsNewest

#
Enumerate over all items, starting with the newest ones.
public IEnumerable<T> ItemsNewest { get; }

ItemsOldest

#
Enumerate over all items, starting with the oldest ones.
public IEnumerable<T> ItemsOldest { get; }

Newest

#
Gets the newest item added to the array. If the array contains no items, default(T) is returned.
public T Newest { get; }

Oldest

#
Gets the oldest item still in the array. If the array contains no items, default(T) is returned.
public T Oldest { get; }

Methods

Add

#
Add an item to the array.
public void Add(
T
item
Item to add.
)

Clear

#
Clear all items in the array.
public void Clear()

GetEnumerator

#
Enumerate over all items in the circular array.
public IEnumerator<T> GetEnumerator()
Explicit

IEnumerable.GetEnumerator

#
IEnumerator IEnumerable.GetEnumerator()

ToArray

#
Create a correctly sized, correctly ordered array representing the current state of the circular array. The items in the returned array are sorted from oldest to newest.
public T[] ToArray()
Array of T.