Struct IntPair
Hand-rolled implementation of ValueTuple<T1,T2> for integers.
Implements
Inherited Members
Namespace: Microsoft.ML.Probabilistic.Collections
Assembly: Microsoft.ML.Probabilistic.dll
Syntax
public readonly struct IntPair : IEquatable<IntPair>
Remarks
Equals(ValueTuple<T1,T2>) uses
Default to implement he comparison. Accessing this
static property involves a lookup in a hash-table each time it is used due to the way
static fields in generic classes are implemented in CLR. It appears to be measurably
slower when (int, int)
is used as a key in a dictionary. To avoid this, this class
specializes Equals()
to integers and thus avoids lookup for comparer.
Constructors
IntPair(Int32, Int32)
Initializes a new instance of the IntPair struct.
Declaration
public IntPair(int first, int second)
Parameters
Type | Name | Description |
---|---|---|
Int32 | first | The first element of the pair. |
Int32 | second | The second element of the pair. |
Properties
First
Gets or sets the first element of the pair.
Declaration
public readonly int First { get; }
Property Value
Type | Description |
---|---|
Int32 |
Second
Gets or sets the second element of the pair.
Declaration
public readonly int Second { get; }
Property Value
Type | Description |
---|---|
Int32 |
Methods
Deconstruct(out Int32, out Int32)
Declaration
public readonly void Deconstruct(out int first, out int second)
Parameters
Type | Name | Description |
---|---|---|
Int32 | first | |
Int32 | second |
Equals(IntPair)
Checks if this object is equal to that
.
Declaration
public readonly bool Equals(IntPair that)
Parameters
Type | Name | Description |
---|---|---|
IntPair | that | The object to compare this object with. |
Returns
Type | Description |
---|---|
Boolean | true if this object is equal to |
Equals(Object)
Checks if this object is equal to that
.
Declaration
public override readonly bool Equals(object that)
Parameters
Type | Name | Description |
---|---|---|
Object | that | The object to compare this object with. |
Returns
Type | Description |
---|---|
Boolean | true if this object is equal to |
Overrides
GetHashCode()
Computes the hash code of this object.
Declaration
public override readonly int GetHashCode()
Returns
Type | Description |
---|---|
Int32 | The computed hash code. |
Overrides
ToString()
Gets the string representation of this pair.
Declaration
public override readonly string ToString()
Returns
Type | Description |
---|---|
String | The string representation of the pair. |