Interface ITwoWayDictionary<T1, T2>
- Namespace
- LfrlAnvil.Collections
- Assembly
- LfrlAnvil.Collections.dll
Represents a generic collection of two-way (forward, reverse) pairs.
public interface ITwoWayDictionary<T1, T2> : IReadOnlyTwoWayDictionary<T1, T2>, IReadOnlyCollection<Pair<T1, T2>>, ICollection<Pair<T1, T2>>, IEnumerable<Pair<T1, T2>>, IEnumerable where T1 : notnull where T2 : notnull
Type Parameters
T1First value type.
T2Second value type.
- Inherited Members
- Extension Methods
Properties
Count
Gets the number of elements contained in the ICollection<T>.
int Count { get; }
Property Value
- int
The number of elements contained in the ICollection<T>.
Methods
Add(T1, T2)
Adds the provided pair.
void Add(T1 first, T2 second)
Parameters
firstT1First value.
secondT2Second value.
Exceptions
- ArgumentException
When either element already exists as key in its respective dictionary.
RemoveForward(T1)
Attempts to remove a pair by its first value.
bool RemoveForward(T1 value)
Parameters
valueT1Entry's key.
Returns
- bool
true when pair was removed, otherwise false.
RemoveForward(T1, out T2)
Attempts to remove a pair by its first value.
bool RemoveForward(T1 value, out T2 second)
Parameters
valueT1Entry's key.
secondT2out parameter that returns second value associated with the removed pair.
Returns
- bool
true when pair was removed, otherwise false.
RemoveReverse(T2)
Attempts to remove a pair by its second value.
bool RemoveReverse(T2 value)
Parameters
valueT2Entry's key.
Returns
- bool
true when pair was removed, otherwise false.
RemoveReverse(T2, out T1)
Attempts to remove a pair by its second value.
bool RemoveReverse(T2 value, out T1 first)
Parameters
valueT2Entry's key.
firstT1out parameter that returns first value associated with the removed pair.
Returns
- bool
true when pair was removed, otherwise false.
TryAdd(T1, T2)
Attempts to add the provided pair.
bool TryAdd(T1 first, T2 second)
Parameters
firstT1First value.
secondT2Second value.
Returns
- bool
true when pair was added, otherwise false.
TryUpdateForward(T1, T2)
Attempts to update the value associated with the specified first key.
bool TryUpdateForward(T1 first, T2 second)
Parameters
firstT1Entry's key.
secondT2Second value to set.
Returns
- bool
true when pair was updated, otherwise false.
TryUpdateReverse(T2, T1)
Attempts to update the value associated with the specified second key.
bool TryUpdateReverse(T2 second, T1 first)
Parameters
secondT2Entry's key.
firstT1First value to set.
Returns
- bool
true when pair was updated, otherwise false.
UpdateForward(T1, T2)
Updates the value associated with the specified first key.
void UpdateForward(T1 first, T2 second)
Parameters
firstT1Entry's key.
secondT2Second value to set.
Exceptions
- ArgumentException
When the provided
secondalready exists as a key.
UpdateReverse(T2, T1)
Updates the value associated with the specified second key.
void UpdateReverse(T2 second, T1 first)
Parameters
secondT2Entry's key.
firstT1First value to set.
Exceptions
- ArgumentException
When the provided
firstalready exists as a key.