Class Map<TLeft, TRight>
Represents a bidirectional one-to-one mapping between two sets of values. Values on each side of the map must be unique within their respective side.
Implements
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 left and right 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 left and right value comparers. |
Properties
| Name | Description |
|---|---|
| Capacity | Gets the number of associations that the map can hold without resizing its internal data structures. |
| Count | Gets the number of associations in the map. |
| this[TLeft] | Gets or sets the right value associated with the specified left value. |
| LeftComparer | Gets the equality comparer used to compare left values in the map. |
| LeftValues | Gets a collection containing the values on the left side of the map. |
| Reverse | Gets a view of this map with the left and right sides swapped. |
| RightComparer | Gets the equality comparer used to compare right values in the map. |
| RightValues | Gets a collection containing the values on the right side of the map. |
Methods
| Name | Description |
|---|---|
| Add(TLeft, TRight) | Adds an association between the specified left and right values to the map. |
| Clear() | Removes all associations from the map. |
| Contains(TLeft, TRight) | Determines whether the map contains an association between the specified left and right values. |
| ContainsLeft(TLeft) | Determines whether the map contains the specified left value. |
| ContainsRight(TRight) | Determines whether the map contains the specified right value. |
| EnsureCapacity(int) | Ensures that the map can hold the specified number of associations without any further expansion of its backing storage. |
| GetAlternateLeftLookup<TAlternateLeft>() | Gets an alternate lookup that can be used to perform operations on this map using |
| GetAlternateLookup<TAlternateLeft, TAlternateRight>() | Gets an alternate lookup that can be used to perform operations on this map using |
| GetEnumerator() | Returns an enumerator that iterates through the left and right value pairs in the map. |
| GetLeftValue(TRight) | Gets the left value associated with the specified right value. |
| GetRightValue(TLeft) | Gets the right value associated with the specified left value. |
| Remove(TLeft, TRight) | Removes the association between the specified left and right values from the map if they are currently associated with each other. |
| RemoveLeft(TLeft) | Removes the association containing the specified left value from the map. |
| RemoveLeft(TLeft, out TRight) | Removes the association containing the specified left value from the map. |
| RemoveRight(TRight) | Removes the association containing the specified right value from the map. |
| RemoveRight(TRight, out TLeft) | Removes the association containing the specified right value from the map. |
| Set(TLeft, TRight) | Sets an association between the specified left and right values, overriding any existing associations involving either value. |
| TrimExcess() | Sets the capacity of the map to what it would be if it had been originally initialized with all its current entries. |
| TrimExcess(int) | Sets the capacity of the map to hold the specified number of associations without any further expansion of its backing storage. |
| TryAdd(TLeft, TRight) | Attempts to add an association between the specified left and right values to the map. |
| TryGetAlternateLeftLookup<TAlternateLeft>(out AlternateLeftLookup<TAlternateLeft>) | Attempts to get an alternate lookup that can be used to perform operations on this map using |
| TryGetAlternateLookup<TAlternateLeft, TAlternateRight>(out AlternateLookup<TAlternateLeft, TAlternateRight>) | Attempts to get an alternate lookup that can be used to perform operations on this map using |
| TryGetLeftValue(TRight, out TLeft) | Attempts to get the left value associated with the specified right value. |
| TryGetRightValue(TLeft, out TRight) | Attempts to get the right value associated with the specified left value. |
Explicit Interface Implementations
| Name | Description |
|---|---|
| IMap<TLeft, TRight>.Reverse | Gets a view of this map with the left and right sides swapped. |
| IReadOnlyMap<TLeft, TRight>.LeftValues | Gets a collection containing the values on the left side of the map. |
| IReadOnlyMap<TLeft, TRight>.Reverse | Gets a view of this map with the left and right sides swapped. |
| IReadOnlyMap<TLeft, TRight>.RightValues | Gets a collection containing the values on the right side of the map. |
| ICollection<KeyValuePair<TLeft, TRight>>.Add(KeyValuePair<TLeft, TRight>) | Adds an association between the specified left and right values to the map. |
| ICollection<KeyValuePair<TLeft, TRight>>.Contains(KeyValuePair<TLeft, TRight>) | Determines whether the map contains an association between the specified left and right values. |
| ICollection<KeyValuePair<TLeft, TRight>>.CopyTo(KeyValuePair<TLeft, TRight>[], int) | Copies the left and right value pairs in the map 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 the association between the specified left and right values from the map if they are currently associated with each other. |
| IDictionary<TLeft, TRight>.ContainsKey(TLeft) | Determines whether the map contains the specified left value. |
| IDictionary<TLeft, TRight>.Keys | Gets a collection containing the values on the left side of the map. |
| IDictionary<TLeft, TRight>.Remove(TLeft) | Removes the association containing the specified left value from the map. |
| IDictionary<TLeft, TRight>.TryGetValue(TLeft, out TRight) | Attempts to get the right value associated with the specified left value. |
| IDictionary<TLeft, TRight>.Values | Gets a collection containing 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 in the map. |
| IReadOnlyDictionary<TLeft, TRight>.ContainsKey(TLeft) | Determines whether the map contains the specified left value. |
| IReadOnlyDictionary<TLeft, TRight>.Keys | Gets a collection containing the values on the left side of the map. |
| IReadOnlyDictionary<TLeft, TRight>.TryGetValue(TLeft, out TRight) | Attempts to get the right value associated with the specified left value. |
| IReadOnlyDictionary<TLeft, TRight>.Values | Gets a collection containing the values on the right side of the map. |
| IEnumerable.GetEnumerator() | Returns an enumerator that iterates through the left and right value pairs in the map. |