Class Map<TLeft, TRight>
Represents a collection of two types of values that map between each other in a bidirectional one-to-one relationship. Values on each side of the map must be unique on their respective side.
Implements
Inherited Members
Namespace: Singulink.Collections
Assembly: Singulink.Collections.dll
Syntax
public class Map<TLeft, TRight> : IMap<TLeft, TRight>, IReadOnlyMap<TLeft, TRight>, IDictionary<TLeft, TRight>, ICollection<KeyValuePair<TLeft, TRight>>, IReadOnlyDictionary<TLeft, TRight>, IReadOnlyCollection<KeyValuePair<TLeft, TRight>>, IEnumerable<KeyValuePair<TLeft, TRight>>, IEnumerable where TLeft : notnull where TRight : notnull
Type Parameters
Name | Description |
---|---|
TLeft | The type of values on the left side of the map. |
TRight | The type of values on the right side of the map. |
Constructors
Name | Description |
---|---|
Map() | Initializes a new instance of the Map<TLeft, TRight> class. |
Map(IEqualityComparer<TLeft>?, IEqualityComparer<TRight>?) | Initializes a new instance of the Map<TLeft, TRight> class with the specified value comparers. |
Map(int) | Initializes a new instance of the Map<TLeft, TRight> class with the specified capacity. |
Map(int, IEqualityComparer<TLeft>?, IEqualityComparer<TRight>?) | Initializes a new instance of the Map<TLeft, TRight> class with the specified capacity and value comparers. |
Properties
Name | Description |
---|---|
Count | Gets the number of mappings contained in the map. |
this[TLeft] | Gets or sets the right value associated with the specified left value. |
LeftValues | Gets the values on the left side of the map. |
Reverse | Gets the reverse map where the left and right side are flipped. |
RightValues | Gets the values on the right side of the map. |
Methods
Name | Description |
---|---|
Add(TLeft, TRight) | Adds an association to map between the specified left and right value. |
Clear() | Removes all mappings from the map. |
Contains(TLeft, TRight) | Gets a value indicating if the map contains an association between the specified left and right value. |
ContainsLeft(TLeft) | Determines whether this map contains the specified left value. |
ContainsRight(TRight) | Determines whether this map contains the specified right value. |
EnsureCapacity(int) | Ensures that this map can hold up to a specified number of entries without any further expansion of its backing storage. |
GetEnumerator() | Returns an enumerator that iterates through the left and right value pairs. |
Remove(TLeft, TRight) | Removes an association from the map between the specified left and right value if they currently map to each other and returns true if removal was successful. If the left and right values do not map to each other then no changes are made and false is returned. |
RemoveLeft(TLeft) | Removes an association from the map given the specified left value. |
RemoveRight(TRight) | Removes an association from the map given the specified right value. |
Set(TLeft, TRight) | Sets an association on the map between the specified left and right value, overriding any previous associations these values had. |
TrimExcess() | Sets the capacity of this map to what it would be if it had been originally initialized with all its entries. |
TrimExcess(int) | Sets the capacity of this map to hold up a specified number of entries without any further expansion of its backing storage. |
TryGetLeftValue(TRight, out TLeft) | Gets the right value associated with the specified left value. |
TryGetRightValue(TLeft, out TRight) | Gets the right value associated with the specified left value. |
Explicit Interface Implementations
Name | Description |
---|---|
IMap<TLeft, TRight>.LeftValues | Gets the values on the left side of the map. |
IMap<TLeft, TRight>.Reverse | Gets the reverse map where the left and right side are flipped. |
IMap<TLeft, TRight>.RightValues | Gets the values on the right side of the map. |
IReadOnlyMap<TLeft, TRight>.LeftValues | Gets the values on the left side of the map. |
IReadOnlyMap<TLeft, TRight>.Reverse | Gets the reverse map where the left and right side are flipped. |
IReadOnlyMap<TLeft, TRight>.RightValues | Gets the values on the right side of the map. |
ICollection<KeyValuePair<TLeft, TRight>>.Add(KeyValuePair<TLeft, TRight>) | Adds an association to map between the specified left and right value. |
ICollection<KeyValuePair<TLeft, TRight>>.Contains(KeyValuePair<TLeft, TRight>) | Gets a value indicating if the map contains an association between the specified left and right value. |
ICollection<KeyValuePair<TLeft, TRight>>.CopyTo(KeyValuePair<TLeft, TRight>[], int) | Copies the left and right value pairs to an array starting at the specified array index. |
ICollection<KeyValuePair<TLeft, TRight>>.IsReadOnly | Gets a value indicating whether the collection is read-only. Always returns false. |
ICollection<KeyValuePair<TLeft, TRight>>.Remove(KeyValuePair<TLeft, TRight>) | Removes an association from the map between the specified left and right value if they currently map to each other and returns true if removal was successful. If the left and right values do not map to each other then no changes are made and false is returned. |
IDictionary<TLeft, TRight>.ContainsKey(TLeft) | Determines whether this map contains the specified left value. |
IDictionary<TLeft, TRight>.Keys | Gets the values on the left side of the map. |
IDictionary<TLeft, TRight>.Remove(TLeft) | Removes an association from the map given the specified left value. |
IDictionary<TLeft, TRight>.TryGetValue(TLeft, out TRight) | Gets the right value associated with the specified left value. |
IDictionary<TLeft, TRight>.Values | Gets the values on the right side of the map. |
IEnumerable<KeyValuePair<TLeft, TRight>>.GetEnumerator() | Returns an enumerator that iterates through the left and right value pairs. |
IReadOnlyDictionary<TLeft, TRight>.ContainsKey(TLeft) | Determines whether this map contains the specified left value. |
IReadOnlyDictionary<TLeft, TRight>.Keys | Gets the values on the left side of the map. |
IReadOnlyDictionary<TLeft, TRight>.TryGetValue(TLeft, out TRight) | Gets the right value associated with the specified left value. |
IReadOnlyDictionary<TLeft, TRight>.Values | Gets the values on the right side of the map. |
IEnumerable.GetEnumerator() | Returns an enumerator that iterates through the left and right value pairs. |