Nito.Collections.Deque by Stephen Cleary

<PackageReference Include="Nito.Collections.Deque" Version="1.2.1" />

 Deque<T>

A double-ended queue (deque), which provides O(1) indexed access, O(1) removals from the front and back, amortized O(1) insertions to the front and back, and O(N) insertions and removals anywhere else (with the operations getting slower as the index approaches the middle).
public int Capacity { get; set; }

Gets or sets the capacity for this deque. This value must always be greater than zero, and this property cannot be set to a value less than Count.

public int Count { get; }

Gets the number of elements contained in this deque.

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

public Deque(int capacity)

Initializes a new instance of the Deque<T> class with the specified capacity.

public Deque(IEnumerable<T> collection)

Initializes a new instance of the Deque<T> class with the elements from the specified collection.

public Deque()

Initializes a new instance of the Deque<T> class.

public void AddToBack(T value)

Inserts a single element at the back of this deque.

public void AddToFront(T value)

Inserts a single element at the front of this deque.

public void Clear()

Removes all items from this deque.

public int IndexOf(T item)

public void Insert(int index, T item)

public void InsertRange(int index, IEnumerable<T> collection)

Inserts a collection of elements into this deque.

public bool Remove(T item)

public void RemoveAt(int index)

public T RemoveFromBack()

Removes and returns the last element of this deque.

public T RemoveFromFront()

Removes and returns the first element of this deque.

public void RemoveRange(int offset, int count)

Removes a range of elements from this deque.

public T[] ToArray()

Creates and returns a new array containing the elements in this deque.