Class KeyedSortedList<TKey, T>
- Namespace
- Stride.Core.Collections
- Assembly
- Stride.Core.dll
List of items, stored sequentially and sorted by an implicit invariant key that are extracted from items by implementing GetKeyForItem(T).
public abstract class KeyedSortedList<TKey, T> : ICollection<T>, IEnumerable<T>, ICollection, IEnumerable where TKey : notnull
Type Parameters
TKeyThe type of the key.
TThe type of the item in the collection.
- Inheritance
-
objectKeyedSortedList<TKey, T>
- Implements
-
ICollection<T>IEnumerable<T>
- Derived
- Extension Methods
Constructors
KeyedSortedList()
protected KeyedSortedList()
KeyedSortedList(IComparer<TKey>?)
protected KeyedSortedList(IComparer<TKey>? comparer)
Parameters
comparerIComparer<TKey>
Fields
items
protected FastListStruct<T> items
Field Value
Properties
Count
Gets the number of elements contained in the ICollection<T>.
public int Count { get; }
Property Value
- int
The number of elements contained in the ICollection<T>.
IsReadOnly
Gets a value indicating whether the ICollection<T> is read-only.
public bool IsReadOnly { get; }
Property Value
- bool
true if the ICollection<T> is read-only; otherwise, false.
this[int]
public T this[int index] { get; set; }
Parameters
indexint
Property Value
- T
this[TKey]
public T this[TKey key] { get; set; }
Parameters
keyTKey
Property Value
- T
Methods
Add(T)
Adds an item to the ICollection<T>.
public void Add(T item)
Parameters
itemTThe object to add to the ICollection<T>.
Exceptions
- NotSupportedException
The ICollection<T> is read-only.
BinarySearch(TKey)
public int BinarySearch(TKey searchKey)
Parameters
searchKeyTKey
Returns
Clear()
Removes all items from the ICollection<T>.
public void Clear()
Exceptions
- NotSupportedException
The ICollection<T> is read-only.
Contains(T)
Determines whether the ICollection<T> contains a specific value.
public bool Contains(T item)
Parameters
itemTThe object to locate in the ICollection<T>.
Returns
- bool
true if
itemis found in the ICollection<T>; otherwise, false.
ContainsKey(TKey)
public bool ContainsKey(TKey key)
Parameters
keyTKey
Returns
GetEnumerator()
public KeyedSortedList<TKey, T>.Enumerator GetEnumerator()
Returns
- KeyedSortedList<TKey, T>.Enumerator
GetKeyForItem(T)
Extracts the key for the specified element.
protected abstract TKey GetKeyForItem(T item)
Parameters
itemTThe element from which to extract the key.
Returns
- TKey
The key for the specified item.
IndexOf(T)
public int IndexOf(T item)
Parameters
itemT
Returns
InsertItem(int, T)
Called every time an item should be added at a given index.
protected virtual void InsertItem(int index, T item)
Parameters
indexintThe index.
itemTThe item.
Remove(TKey)
public bool Remove(TKey key)
Parameters
keyTKey
Returns
Remove(T)
public void Remove(T item)
Parameters
itemT
RemoveItem(int)
Called every time an item should be removed at a given index.
protected virtual void RemoveItem(int index)
Parameters
indexintThe index.
Sort()
Sorts again this list (in case keys were mutated).
public void Sort()
TryGetValue(TKey, out T)
public bool TryGetValue(TKey key, out T value)
Parameters
keyTKeyvalueT