Table of Contents

Class SortedList<TKey, TValue>

Namespace
Stride.Core.Collections
Assembly
Stride.Core.dll

Represents a collection of associated keys and values that are sorted by the keys and are accessible by key and by index.

public class SortedList<TKey, TValue> : IDictionary<TKey, TValue>, ICollection<KeyValuePair<TKey, TValue>>, IEnumerable<KeyValuePair<TKey, TValue>>, IDictionary, ICollection, IEnumerable

Type Parameters

TKey
TValue
Inheritance
SortedList<TKey, TValue>
Implements
IDictionary<TKey, TValue>
ICollection<KeyValuePair<TKey, TValue>>
IEnumerable<KeyValuePair<TKey, TValue>>
Extension Methods

Constructors

SortedList()

public SortedList()

SortedList(IComparer<TKey>)

public SortedList(IComparer<TKey> comparer)

Parameters

comparer IComparer<TKey>

SortedList(IDictionary<TKey, TValue>)

public SortedList(IDictionary<TKey, TValue> dictionary)

Parameters

dictionary IDictionary<TKey, TValue>

SortedList(IDictionary<TKey, TValue>, IComparer<TKey>)

public SortedList(IDictionary<TKey, TValue> dictionary, IComparer<TKey> comparer)

Parameters

dictionary IDictionary<TKey, TValue>
comparer IComparer<TKey>

SortedList(int)

public SortedList(int capacity)

Parameters

capacity int

SortedList(int, IComparer<TKey>)

public SortedList(int capacity, IComparer<TKey> comparer)

Parameters

capacity int
comparer IComparer<TKey>

Properties

Capacity

public int Capacity { get; set; }

Property Value

int

Comparer

public IComparer<TKey> Comparer { get; }

Property Value

IComparer<TKey>

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[TKey]

Gets or sets the element with the specified key.

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

Parameters

key TKey

The key of the element to get or set.

Property Value

TValue

The element with the specified key.

Exceptions

ArgumentNullException

key is null.

KeyNotFoundException

The property is retrieved and key is not found.

NotSupportedException

The property is set and the IDictionary<TKey, TValue> is read-only.

Keys

public IList<TKey> Keys { get; }

Property Value

IList<TKey>

Values

public IList<TValue> Values { get; }

Property Value

IList<TValue>

Methods

Add(TKey, TValue)

Adds an element with the provided key and value to the IDictionary<TKey, TValue>.

public void Add(TKey key, TValue value)

Parameters

key TKey

The object to use as the key of the element to add.

value TValue

The object to use as the value of the element to add.

Exceptions

ArgumentNullException

key is null.

ArgumentException

An element with the same key already exists in the IDictionary<TKey, TValue>.

NotSupportedException

The IDictionary<TKey, TValue> is read-only.

Clear()

Removes all elements from the IDictionary object.

public void Clear()

Exceptions

NotSupportedException

The IDictionary object is read-only.

ContainsKey(TKey)

Determines whether the IDictionary<TKey, TValue> contains an element with the specified key.

public bool ContainsKey(TKey key)

Parameters

key TKey

The key to locate in the IDictionary<TKey, TValue>.

Returns

bool

true if the IDictionary<TKey, TValue> contains an element with the key; otherwise, false.

Exceptions

ArgumentNullException

key is null.

ContainsValue(TValue)

public bool ContainsValue(TValue value)

Parameters

value TValue

Returns

bool

GetEnumerator()

public SortedList<TKey, TValue>.Enumerator GetEnumerator()

Returns

SortedList<TKey, TValue>.Enumerator

IndexOfKey(TKey)

public int IndexOfKey(TKey key)

Parameters

key TKey

Returns

int

IndexOfValue(TValue)

public int IndexOfValue(TValue value)

Parameters

value TValue

Returns

int

Remove(TKey)

Removes the element with the specified key from the IDictionary<TKey, TValue>.

public bool Remove(TKey key)

Parameters

key TKey

The key of the element to remove.

Returns

bool

true if the element is successfully removed; otherwise, false. This method also returns false if key was not found in the original IDictionary<TKey, TValue>.

Exceptions

ArgumentNullException

key is null.

NotSupportedException

The IDictionary<TKey, TValue> is read-only.

RemoveAt(int)

public void RemoveAt(int index)

Parameters

index int

TrimExcess()

public void TrimExcess()

TryGetValue(TKey, out TValue)

Gets the value associated with the specified key.

public bool TryGetValue(TKey key, out TValue value)

Parameters

key TKey

The key whose value to get.

value TValue

When this method returns, the value associated with the specified key, if the key is found; otherwise, the default value for the type of the value parameter. This parameter is passed uninitialized.

Returns

bool

true if the object that implements IDictionary<TKey, TValue> contains an element with the specified key; otherwise, false.

Exceptions

ArgumentNullException

key is null.