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

Nito.Collections.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; }

Gets or sets the item at the specified index.

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.

Returns an enumerator that iterates through the collection.

public int IndexOf(T item)

Determines the index of a specific item in this list.

public void Insert(int index, T item)

Inserts an item to this list at the specified index.

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

Inserts a collection of elements into this deque.

public bool Remove(T item)

Removes the first occurrence of a specific object from this list.

public void RemoveAt(int index)

Removes the item at the specified 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.