Table of Contents

Class CircularArray<T>

Namespace
Aplib.Core.Collections
Assembly
Aplib.Core.dll

An array that wraps around when it reaches its end. Functionally works like a queue with indexing.

public class CircularArray<T>

Type Parameters

T
Inheritance
CircularArray<T>
Inherited Members

Constructors

CircularArray(int)

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

public CircularArray(int size)

Parameters

size int

The size of the array.

CircularArray(T[])

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

public CircularArray(T[] array)

Parameters

array T[]

An array to use as the circular array.

Properties

this[int]

Gets the element at the specified index.

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

Parameters

index int

The index of the element to get.

Property Value

T

The element at the specified index.

Length

The length of the array.

public int Length { get; }

Property Value

int

Methods

GetFirst()

Gets the first element of the array.

public T GetFirst()

Returns

T

The last element of the array

GetHead()

Gets the element at the head of the array.

public T GetHead()

Returns

T

The element at the head of the array

Put(T)

Puts an element at the start of the array.

public void Put(T value)

Parameters

value T

The element to add to the array

ToArray(int, int)

Converts the circular array to an array. The head should be the last element of the array. Copies from start to end inclusive.

public T[] ToArray(int start = 0, int end = -1)

Parameters

start int

The start index of the range to copy.

end int

The end index of the range to copy.

Returns

T[]

The circular array as a normal array