Skip to main content

OpenTD reference 2026 R1

Class UniqueItemList<T\>

Last update: 09.03.2026

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)

[DataContract]
public class UniqueItemList<T> : IList<T>, ICollection<T>, IEnumerable<T>, IEnumerable

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 .

public int Count { get; }

Property Value

int

IsReadOnly

Gets a value indicating whether the is read-only.

public bool IsReadOnly { get; }

Property Value

bool

this[int]

Gets or sets the element at the specified index.

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

Property Value

T

Exceptions

ArgumentOutOfRangeException

index is not a valid index in the .

NotSupportedException

The property is set and the is read-only.

Methods

Add(T)

Will remove any existing item that equals the added item.

public void Add(T item)

Parameters

item T

Clear()

Removes all items from the .

public void Clear()

Exceptions

NotSupportedException

The is read-only.

Contains(T)

Determines whether the contains a specific value.

public bool Contains(T item)

Parameters

item T

The object to locate in the .

Returns

bool

true if item is found in the ; otherwise, false.

CopyTo(T[], int)

Copies the elements of the to an , starting at a particular index.

public void CopyTo(T[] array, int arrayIndex)

Parameters

array T[]

The one-dimensional that is the destination of the elements copied from . The 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 is greater than the available space from arrayIndex to the end of the destination array.

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.

IndexOf(T)

Determines the index of a specific item in the .

public int IndexOf(T item)

Parameters

item T

The object to locate in the .

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.

public void Insert(int index, T item)

Parameters

index int

item T

Remove(T)

Removes the first occurrence of a specific object from the .

public bool Remove(T item)

Parameters

item T

The object to remove from the .

Returns

bool

true if item was successfully removed from the ; otherwise, false. This method also returns false if item is not found in the original .

Exceptions

NotSupportedException

The is read-only.

RemoveAll(Predicate<T>)

public int RemoveAll(Predicate<T> match)

Parameters

match Predicate<T>

Returns

int

RemoveAt(int)

Removes the item at the specified index.

public void RemoveAt(int index)

Parameters

index int

The zero-based index of the item to remove.

Exceptions

ArgumentOutOfRangeException

index is not a valid index in the .

NotSupportedException

The is read-only.

Connect with Ansys