Interface IBidirectionalMap<TKey, TVal>
Interface for bi-directional maps which allow to access key by value in addition to usual by key lookup.
Assembly: Eco.Shared.dll
Syntax
public interface IBidirectionalMap<TKey, TVal> : IDictionary<TKey, TVal>, ICollection<KeyValuePair<TKey, TVal>>, IEnumerable<KeyValuePair<TKey, TVal>>, IEnumerable
Type Parameters
Name |
Description |
TKey |
|
TVal |
|
Methods
ContainsValue(TVal)
Checks if value is in map.
Declaration
bool ContainsValue(TVal val)
Parameters
Type |
Name |
Description |
TVal |
val |
|
Returns
Type |
Description |
System.Boolean |
|
GetOrAdd(TKey, TVal)
Gets value by key or adds new mapping if not exits.
Declaration
TVal GetOrAdd(TKey key, TVal value)
Parameters
Type |
Name |
Description |
TKey |
key |
|
TVal |
value |
|
Returns
GetOrAdd(TKey, Func<TVal>)
Gets value by key or adds new mapping if not exits. Value will be created with valueFactory
.
Declaration
TVal GetOrAdd(TKey key, Func<TVal> valueFactory)
Parameters
Type |
Name |
Description |
TKey |
key |
|
System.Func<TVal> |
valueFactory |
|
Returns
TryAdd(TKey, TVal)
Tries to add two-way mapping between key
and value
. Fails if either key or value already exists in the dictionary.
Declaration
bool TryAdd(TKey key, TVal value)
Parameters
Type |
Name |
Description |
TKey |
key |
|
TVal |
value |
|
Returns
Type |
Description |
System.Boolean |
|
TryGetByValue(TVal, out TKey)
Declaration
bool TryGetByValue(TVal val, out TKey key)
Parameters
Type |
Name |
Description |
TVal |
val |
|
TKey |
key |
|
Returns
Type |
Description |
System.Boolean |
|
Extension Methods