Class UniqueItemList<T\>
Last update: 09.03.2026Namespace: 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)
[MessagePackObject(true)]
public class UniqueItemList<T> : IList<T>, ICollection<T>, IEnumerable<T>, IEnumerable
Type Parameters
T
Inheritance
Implements
IList<T>, ICollection<T>, IEnumerable<T>, IEnumerable
Inherited Members
object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.MemberwiseClone(), object.ReferenceEquals(object?, object?), object.ToString()
Properties
Count
Gets the number of elements contained in the
public int Count { get; }
Property Value
IsReadOnly
Gets a value indicating whether the
public bool IsReadOnly { get; }
Property Value
this[int]
Gets or sets the element at the specified index.
public T this[int index] { get; set; }
Property Value
T
Exceptions
index is not a valid index in the
The property is set and the
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
The
Contains(T)
Determines whether the
public bool Contains(T item)
Parameters
item T
The object to locate in the
Returns
true if item is found in the
CopyTo(T[], int)
Copies the elements of the
public void CopyTo(T[] array, int arrayIndex)
Parameters
array T[]
The one-dimensional
arrayIndex int
The zero-based index in array at which copying begins.
Exceptions
array is null.
arrayIndex is less than 0.
The number of elements in the source 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
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
true if item was successfully removed from the item is not found in the original
Exceptions
The
RemoveAll(Predicate<T>)
public int RemoveAll(Predicate<T> match)
Parameters
match Predicate<T>
Returns
RemoveAt(int)
Removes the
public void RemoveAt(int index)
Parameters
index int
The zero-based index of the item to remove.
Exceptions
index is not a valid index in the
The