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
TKey
The first object type.
TValue
The 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
capacity
intThe 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
key
TKeyThe first object.
value
TValueThe second object to map to.
Returns
- bool
true
if the key value pair was successfully registered.false
if the key or value already existed.
GetKey(TValue)
Gets the key to which the provided value was assigned.
public TKey? GetKey(TValue value)
Parameters
value
TValueThe 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
key
TKeyThe 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.