TupleComparisons.CompositeComparer<T1, T2>
Namespace: SnowBank.Data.Tuples · class
Implements: IComparer<IVarTuple>, IComparer<STuple<T1, T2>>, IComparer<(T1, T2)>
Comparer that compares tuples with at least 2 items
Constructors
CompositeComparer<T1, T2>
CompositeComparer<T1, T2>()
Constructor for a new tuple comparer
CompositeComparer<T1, T2>(IComparer<T1> comparer1, IComparer<T2> comparer2)
Constructor for a new tuple comparer
CompositeComparer<T1, T2>(int offset, IComparer<T1> comparer1, IComparer<T2> comparer2)
Constructor for a new tuple comparer
offset— Offset in the tuples of the first element to compare (can be negative)comparer1— Comparer for the first element typecomparer2— Comparer for the second element type
Properties
Comparer1
IComparer<T1> Comparer1 { get; }
Comparer for the first element (at position Offset)
Comparer2
IComparer<T2> Comparer2 { get; }
Comparer for the second element (at position Offset + 1)
Offset
int Offset { get; }
Offset in the tuples where the comparison starts
If negative, comparison starts from the end.
Methods
Compare
int Compare(IVarTuple x, IVarTuple y)
Compare up to two items in both tuples
x— First tupley— Second tuple
Returns: Returns a positive value if x is greater than y, a negative value if x is less than y and 0 if x is equal to y.
int Compare(STuple<T1, T2> x, STuple<T1, T2> y)
Compare two tuples
x— First tupley— Second tuple
Returns: Returns a positive value if x is greater than y, a negative value if x is less than y and 0 if x is equal to y.
int Compare((T1, T2) x, (T1, T2) y)
Compare two tuples
x— First tupley— Second tuple
Returns: Returns a positive value if x is greater than y, a negative value if x is less than y and 0 if x is equal to y.
Fields
Default
static readonly IComparer<IVarTuple> Default