Table of Contents

Class BiDictionary<TKey, TValue>

Namespace
Csra
Assembly
Csra.dll

Represents a bidirectional dictionary that allows lookups in both directions.

[Serializable]
public class BiDictionary<TKey, TValue> : IEnumerable<KeyValuePair<TKey, TValue>>, IEnumerable

Type Parameters

TKey

The type of the keys.

TValue

The type of the values.

Inheritance
BiDictionary<TKey, TValue>
Implements
IEnumerable<KeyValuePair<TKey, TValue>>
Inherited Members

Properties

Count

Gets the number of key/value pairs contained in the BiDictionary.

public int Count { get; }

Property Value

int

Methods

Add(TKey, TValue)

Adds a key/value pair to the BiDictionary if the key does not already exist.

public void Add(TKey key, TValue value)

Parameters

key TKey

They key to be added.

value TValue

The value of the element to add.

Clear()

Removes all keys and values from the BiDictionary.

public void Clear()

ContainsKey(TKey)

Determines wheter the BiDictionary contains the specified key.

public bool ContainsKey(TKey key)

Parameters

key TKey

The key to locate in the BiDictionary.

Returns

bool

true if the BiDictionary contains an element with the specified key; otherwise, false.

ContainsValue(TValue)

Determines wheter the BiDictionary contains the specified value.

public bool ContainsValue(TValue value)

Parameters

value TValue

The value to locate in the BiDictionary.

Returns

bool

true if the BiDictionary contains an element with the specified value; otherwise, false.

GetEnumerator()

Gets a collection containing the keys in the BiDictionary.

public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator()

Returns

IEnumerator<KeyValuePair<TKey, TValue>>

RemoveByKey(TKey)

Removes the key/value pair with the specified key from the BiDictionary.

public bool RemoveByKey(TKey key)

Parameters

key TKey

The key of the element to remove.

Returns

bool

true if the element is successfully found and removed; otherwise false.

RemoveByValue(TValue)

Removes the key/value pair with the specified value from the BiDictionary.

public bool RemoveByValue(TValue value)

Parameters

value TValue

Returns

bool

true if the element is successfully found and removed; otherwise false.

TryGetKey(TValue, out TKey)

Gets the key associated with the specified value.

public bool TryGetKey(TValue value, out TKey key)

Parameters

value TValue

The value of the key to get.

key TKey

When this methods returns, contains the key associated with the specified value, if the value is found; otherwise, false.

Returns

bool

true if the BiDictionary contains an element with the specified value; otherwise, false.

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 of the value to get.

value TValue

When this methods returns, contains the value associated with the specified key, if the key is found; otherwise, false.

Returns

bool

true if the BiDictionary contains an element with the specified key; otherwise, false.