Table of Contents

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

Type Parameters

TKey

The type of the key.

T

The type of the item in the collection.

Inheritance
KeyedSortedList<TKey, T>
Implements
Derived
Extension Methods

Constructors

KeyedSortedList()

protected KeyedSortedList()

KeyedSortedList(IComparer<TKey>)

protected KeyedSortedList(IComparer<TKey> comparer)

Parameters

comparer IComparer<TKey>

Fields

items

protected FastListStruct<T> items

Field Value

FastListStruct<T>

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>.

this[int]

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

Parameters

index int

Property Value

T

this[TKey]

public T this[TKey key] { get; set; }

Parameters

key TKey

Property Value

T

Methods

Add(T)

Adds an item to the ICollection<T>.

public void Add(T item)

Parameters

item T

The object to add to the ICollection<T>.

Exceptions

NotSupportedException

The ICollection<T> is read-only.

BinarySearch(TKey)

public int BinarySearch(TKey searchKey)

Parameters

searchKey TKey

Returns

int

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

item T

The object to locate in the ICollection<T>.

Returns

bool

true if item is found in the ICollection<T>; otherwise, false.

ContainsKey(TKey)

public bool ContainsKey(TKey key)

Parameters

key TKey

Returns

bool

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

item T

The element from which to extract the key.

Returns

TKey

The key for the specified item.

IndexOf(T)

public int IndexOf(T item)

Parameters

item T

Returns

int

InsertItem(int, T)

Called every time an item should be added at a given index.

protected virtual void InsertItem(int index, T item)

Parameters

index int

The index.

item T

The item.

Remove(TKey)

public bool Remove(TKey key)

Parameters

key TKey

Returns

bool

Remove(T)

public void Remove(T item)

Parameters

item T

RemoveItem(int)

Called every time an item should be removed at a given index.

protected virtual void RemoveItem(int index)

Parameters

index int

The 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

key TKey
value T

Returns

bool