Table of Contents

Class ResizeableArray<T>

Namespace
AlgorithmsSW.List
Assembly
AlgorithmsSW.dll

Represents a generic list of items.

public sealed class ResizeableArray<T> : IRandomAccessList<T>, IReadonlyRandomAccessList<T>, IEnumerable<T>, IEnumerable

Type Parameters

T

The type of items contained in the list.

Inheritance
ResizeableArray<T>
Implements
Inherited Members
Extension Methods

Constructors

ResizeableArray(int)

Represents a generic list of items.

public ResizeableArray(int capacity = 16)

Parameters

capacity int

The initial capacity of the list.

Exceptions

ArgumentException

capacity is negative.

Fields

Empty

public static ResizeableArray<int> Empty

Field Value

ResizeableArray<int>

Exceptions

ArgumentException

capacity is negative.

Properties

Capacity

Gets the capacity for this instance, that is the maximum number of items it can hold without resizing.

public int Capacity { get; }

Property Value

int

Exceptions

ArgumentException

capacity is negative.

Count

Gets the number of elements in the list.

public int Count { get; }

Property Value

int

Exceptions

ArgumentException

capacity is negative.

IsEmpty

Gets a value indicating whether the list is empty.

public bool IsEmpty { get; }

Property Value

bool

Exceptions

ArgumentException

capacity is negative.

IsFull

Gets a value indicating whether the ResizeableArray<T> is full, that is Count equals Capacity.

public bool IsFull { get; }

Property Value

bool

Exceptions

ArgumentException

capacity is negative.

this[int]

Gets or sets the item at the specified index.

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

Parameters

index int

The index of the item to get or set.

Property Value

T

Exceptions

ArgumentException

capacity is negative.

Methods

Add(T)

Adds an item to the end of the ResizeableArray<T>.

public void Add(T item)

Parameters

item T

Exceptions

ArgumentException

capacity is negative.

Clear()

Removes all items from the ResizeableArray<T>.

public void Clear()

Exceptions

ArgumentException

capacity is negative.

GetEnumerator()

Returns an enumerator that iterates through the collection.

public IEnumerator<T> GetEnumerator()

Returns

IEnumerator<T>

An enumerator that can be used to iterate through the collection.

Exceptions

ArgumentException

capacity is negative.

InsertAt(T, int)

Inserts an item at the beginning of the ResizeableArray<T>.

public void InsertAt(T item, int index = 0)

Parameters

item T

The item to insert.

index int

The index at which to insert the item.

Exceptions

ArgumentException

capacity is negative.

Remove(T)

public bool Remove(T item)

Parameters

item T

Returns

bool

Exceptions

ArgumentException

capacity is negative.

Remove(T, IEqualityComparer<T>)

public bool Remove(T item, IEqualityComparer<T> comparer)

Parameters

item T
comparer IEqualityComparer<T>

Returns

bool

Exceptions

ArgumentException

capacity is negative.

RemoveAt(int)

Deletes the item at the specified index.

public T RemoveAt(int index = 0)

Parameters

index int

The index of the item to delete.

Returns

T

The deleted item.

Exceptions

ArgumentException

capacity is negative.

RemoveLast()

Removes the last item from the ResizeableArray<T>.

public T RemoveLast()

Returns

T

The removed item.

Exceptions

ArgumentException

capacity is negative.

RemoveLast(int)

Removes the last n items from the ResizeableArray<T>.

public void RemoveLast(int n)

Parameters

n int

The number of items to remove.

Exceptions

ArgumentException

capacity is negative.

SetCount(int)

Sets the Count to the specified value, growing the ResizeableArray<T> if necessary.

public void SetCount(int newCount)

Parameters

newCount int

The new value for Count.

Exceptions

ArgumentException

capacity is negative.

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.

Exceptions

ArgumentException

capacity is negative.