Skip to main content
Namespace: OpenTD.Utility
Assembly: OpenTD.dll
Acts like a List, except Add and Insert will remove existing items that equal the added/inserted item (according to its definition of Equals)

Type Parameters

T

Inheritance

object ← UniqueItemList<T>

Implements

IList<T>, ICollection<T>, IEnumerable<T>, IEnumerable

Inherited Members

object.ToString(), object.Equals(object), object.Equals(object, object), object.ReferenceEquals(object, object), object.GetHashCode(), object.GetType(), object.MemberwiseClone()

Properties

Count

Gets the number of elements contained in the ICollection`1.

Property Value

int

IsReadOnly

Gets a value indicating whether the ICollection`1 is read-only.

Property Value

bool

this[int]

Gets or sets the element at the specified index.

Property Value

T

Exceptions

ArgumentOutOfRangeException index is not a valid index in the IList`1. NotSupportedException The property is set and the IList`1 is read-only.

Methods

Add(T)

Will remove any existing item that equals the added item.

Parameters

item T

Clear()

Removes all items from the ICollection`1.

Exceptions

NotSupportedException The ICollection`1 is read-only.

Contains(T)

Determines whether the ICollection`1 contains a specific value.

Parameters

item T The object to locate in the ICollection`1.

Returns

bool true if item is found in the ICollection`1; otherwise, false.

CopyTo(T[], int)

Copies the elements of the ICollection`1 to an Array, starting at a particular Array index.

Parameters

array T[] The one-dimensional Array that is the destination of the elements copied from ICollection`1. The Array must have zero-based indexing. arrayIndex int The zero-based index in array at which copying begins.

Exceptions

ArgumentNullException array is null. ArgumentOutOfRangeException arrayIndex is less than 0. ArgumentException The number of elements in the source ICollection`1 is greater than the available space from arrayIndex to the end of the destination array.

GetEnumerator()

Returns an enumerator that iterates through the collection.

Returns

IEnumerator<T> An enumerator that can be used to iterate through the collection.

IndexOf(T)

Determines the index of a specific item in the IList`1.

Parameters

item T The object to locate in the IList`1.

Returns

int The index of item if found in the list; otherwise, -1.

Insert(int, T)

Will remove any existing item that equals the inserted item.

Parameters

index int item T

Remove(T)

Removes the first occurrence of a specific object from the ICollection`1.

Parameters

item T The object to remove from the ICollection`1.

Returns

bool true if item was successfully removed from the ICollection1; otherwise, [false](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool). This method also returns [false](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) if <code className="paramref">item</code> is not found in the original ICollection1.

Exceptions

NotSupportedException The ICollection`1 is read-only.

RemoveAll(Predicate<T>)

Parameters

match Predicate<T>

Returns

int

RemoveAt(int)

Removes the IList`1 item at the specified index.

Parameters

index int The zero-based index of the item to remove.

Exceptions

ArgumentOutOfRangeException index is not a valid index in the IList`1. NotSupportedException The IList`1 is read-only.