Class OneToOneRelation<TKey, TValue>
- Namespace
- AsmResolver.Collections
- Assembly
- AsmResolver.dll
Describes a one-to-one relation between two object types, with an efficient lookup time for both keys and values.
public sealed class OneToOneRelation<TKey, TValue> where TKey : notnull where TValue : notnull
Type Parameters
TKeyThe first object type.
TValueThe second object type.
- Inheritance
-
OneToOneRelation<TKey, TValue>
- Inherited Members
Constructors
OneToOneRelation()
Creates a new, empty one-to-one mapping.
public OneToOneRelation()
OneToOneRelation(int)
Creates a new, empty one-to-one mapping.
public OneToOneRelation(int capacity)
Parameters
capacityintThe initial number of elements the relation can store.
Methods
Add(TKey, TValue)
Registers a one-to-one relation between two objects.
public bool Add(TKey key, TValue value)
Parameters
keyTKeyThe first object.
valueTValueThe second object to map to.
Returns
- bool
trueif the key value pair was successfully registered.falseif the key or value already existed.
GetKey(TValue)
Gets the key to which the provided value was assigned.
public TKey? GetKey(TValue value)
Parameters
valueTValueThe value.
Returns
- TKey
The key.
GetKeys()
Gets all keys stored in the one-to-one mapping.
public IEnumerable<TKey> GetKeys()
Returns
- IEnumerable<TKey>
The keys.
GetValue(TKey)
Gets the value that was assigned to the provided key.
public TValue? GetValue(TKey key)
Parameters
keyTKeyThe key.
Returns
- TValue
The value.
GetValues()
Gets all values stored in the one-to-one mapping.
public IEnumerable<TValue> GetValues()
Returns
- IEnumerable<TValue>
The values.