Class OneToManyRelation<TKey, TValue>
- Namespace
- AsmResolver.Collections
- Assembly
- AsmResolver.dll
Represents a one-to-many relation, where an object is mapped to a collection of other objects.
public sealed class OneToManyRelation<TKey, TValue> where TKey : notnull where TValue : notnull
Type Parameters
TKey
The type of objects to map.
TValue
The type of objects to map to.
- Inheritance
-
OneToManyRelation<TKey, TValue>
- Inherited Members
Constructors
OneToManyRelation()
Creates a new, empty one-to-many relation mapping.
public OneToManyRelation()
OneToManyRelation(int)
Creates a new, empty one-to-many relation mapping.
public OneToManyRelation(int capacity)
Parameters
capacity
intThe initial number of elements the relation can store.
Methods
Add(TKey, TValue)
Registers a 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 there already exists a key that maps to the provided value.
GetKey(TValue)
Gets the key that maps to the provided value.
public TKey? GetKey(TValue value)
Parameters
value
TValueThe value.
Returns
- TKey
The key.
GetValues(TKey)
Gets a collection of values the provided key maps to.
public OneToManyRelation<TKey, TValue>.ValueSet GetValues(TKey key)
Parameters
key
TKeyThe key.
Returns
- OneToManyRelation<TKey, TValue>.ValueSet
The values.