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
TKeyThe type of the keys.
TValueThe 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
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
keyTKeyThey key to be added.
valueTValueThe 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
keyTKeyThe key to locate in the BiDictionary.
Returns
ContainsValue(TValue)
Determines wheter the BiDictionary contains the specified value.
public bool ContainsValue(TValue value)
Parameters
valueTValueThe value to locate in the BiDictionary.
Returns
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
keyTKeyThe key of the element to remove.
Returns
RemoveByValue(TValue)
Removes the key/value pair with the specified value from the BiDictionary.
public bool RemoveByValue(TValue value)
Parameters
valueTValue
Returns
TryGetKey(TValue, out TKey)
Gets the key associated with the specified value.
public bool TryGetKey(TValue value, out TKey key)
Parameters
valueTValueThe value of the key to get.
keyTKeyWhen this methods returns, contains the key associated with the specified value, if the value is found; otherwise, false.
Returns
TryGetValue(TKey, out TValue)
Gets the value associated with the specified key.
public bool TryGetValue(TKey key, out TValue value)
Parameters
keyTKeyThe key of the value to get.
valueTValueWhen this methods returns, contains the value associated with the specified key, if the key is found; otherwise, false.