Table of Contents

Class IndexedList<K, V>

Namespace
Utils.Collections
Assembly
Utils.dll

Indexed list.

public class IndexedList<K, V> : ICollection<V>, IEnumerable<V>, IReadOnlyDictionary<K, V>, IReadOnlyCollection<KeyValuePair<K, V>>, IEnumerable<KeyValuePair<K, V>>, IEnumerable where K : notnull

Type Parameters

K

Key structure

V

Value structure

Inheritance
IndexedList<K, V>
Implements
Inherited Members
Extension Methods

Constructors

IndexedList(Func<V, K>)

Indexed list.

public IndexedList(Func<V, K> getKey)

Parameters

getKey Func<V, K>

Key extraction function

IndexedList(Func<V, K>, IEnumerable<V>)

Indexed list.

public IndexedList(Func<V, K> getKey, IEnumerable<V> values)

Parameters

getKey Func<V, K>

Key extraction function

values IEnumerable<V>

Initial values

Properties

Count

Number of stored values.

public int Count { get; }

Property Value

int

IsReadOnly

Read/write.

public bool IsReadOnly { get; }

Property Value

bool

this[K]

Retrieves a value.

public V this[K key] { get; }

Parameters

key K

Key

Property Value

V

Corresponding value

Keys

Set of keys.

public IEnumerable<K> Keys { get; }

Property Value

IEnumerable<K>

Values

Set of values.

public IEnumerable<V> Values { get; }

Property Value

IEnumerable<V>

Methods

Add(V)

Adds a value.

public void Add(V item)

Parameters

item V

Value

Clear()

Removes all elements.

public void Clear()

Contains(V)

Indicates if the list contains the parameter value.

public bool Contains(V item)

Parameters

item V

Value

Returns

bool

true if the value is in the list; otherwise, false

ContainsKey(K)

Indicates if the list contains the parameter key.

public bool ContainsKey(K key)

Parameters

key K

Key

Returns

bool

true if the key is in the list; otherwise, false

CopyTo(V[], int)

Copies to an array.

public void CopyTo(V[] array, int arrayIndex)

Parameters

array V[]

Target array

arrayIndex int

Starting index

Remove(K)

Removes a value by its key.

public bool Remove(K key)

Parameters

key K

Key to remove

Returns

bool

true if the value was removed; otherwise, false

Remove(V)

Removes a value.

public bool Remove(V item)

Parameters

item V

Value to remove

Returns

bool

true if the value was removed; otherwise, false

TryGetValue(K, out V)

Tries to get a value.

public bool TryGetValue(K key, out V value)

Parameters

key K

Key

value V

Output value

Returns

bool

true if the value was retrieved; otherwise, false