Table of Contents

Class IndexingDictionary<T>

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

A dictionary that maps index values to items. It uses a sparse list internally for storage.

[DataSerializer(typeof(IndexingDictionarySerializer<>), Mode = DataSerializerGenericMode.GenericArguments)]
public class IndexingDictionary<T> : IDictionary<int, T>, ICollection<KeyValuePair<int, T>>, IEnumerable<KeyValuePair<int, T>>, IEnumerable where T : class

Type Parameters

T

The type of item indexed in this collection.

Inheritance
IndexingDictionary<T>
Implements
Extension Methods

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]

Gets or sets the element with the specified key.

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

Parameters

index int

Property Value

T

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

Gets an ICollection<T> containing the keys of the IDictionary<TKey, TValue>.

public ICollection<int> Keys { get; }

Property Value

ICollection<int>

An ICollection<T> containing the keys of the object that implements IDictionary<TKey, TValue>.

Values

Gets an ICollection<T> containing the values in the IDictionary<TKey, TValue>.

public ICollection<T> Values { get; }

Property Value

ICollection<T>

An ICollection<T> containing the values in the object that implements IDictionary<TKey, TValue>.

Methods

Add(KeyValuePair<int, T>)

Adds an item to the ICollection<T>.

public void Add(KeyValuePair<int, T> item)

Parameters

item KeyValuePair<int, T>

The object to add to the ICollection<T>.

Exceptions

NotSupportedException

The ICollection<T> is read-only.

Add(int, T)

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

public void Add(int key, T value)

Parameters

key int

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

value T

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 items from the ICollection<T>.

public void Clear()

Exceptions

NotSupportedException

The ICollection<T> is read-only.

Contains(KeyValuePair<int, T>)

Determines whether the ICollection<T> contains a specific value.

public bool Contains(KeyValuePair<int, T> item)

Parameters

item KeyValuePair<int, T>

The object to locate in the ICollection<T>.

Returns

bool

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

ContainsKey(int)

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

public bool ContainsKey(int index)

Parameters

index int

Returns

bool

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

Exceptions

ArgumentNullException

key is null.

CopyTo(KeyValuePair<int, T>[], int)

Copies the elements of the ICollection<T> to an Array, starting at a particular Array index.

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

Parameters

array KeyValuePair<int, T>[]

The one-dimensional Array that is the destination of the elements copied from ICollection<T>. The Array 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 ICollection<T> 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<KeyValuePair<int, T>> GetEnumerator()

Returns

IEnumerator<KeyValuePair<int, T>>

An enumerator that can be used to iterate through the collection.

Remove(KeyValuePair<int, T>)

Removes the first occurrence of a specific object from the ICollection<T>.

public bool Remove(KeyValuePair<int, T> item)

Parameters

item KeyValuePair<int, T>

The object to remove from the ICollection<T>.

Returns

bool

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

Exceptions

NotSupportedException

The ICollection<T> is read-only.

Remove(int)

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

public bool Remove(int index)

Parameters

index int

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.

SafeGet(int)

public T SafeGet(int index)

Parameters

index int

Returns

T

TryGetValue(int, out T)

Gets the value associated with the specified key.

public bool TryGetValue(int key, out T value)

Parameters

key int

The key whose value to get.

value T

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.