TupleComparisons.CompositeComparer<T1, T2, T3>

Namespace: SnowBank.Data.Tuples · class

Implements: IComparer<IVarTuple>, IComparer<STuple<T1, T2, T3>>, IComparer<(T1, T2, T3)>

Comparer that compares tuples with at least 3 items

Constructors

CompositeComparer<T1, T2, T3>

CompositeComparer<T1, T2, T3>()

Constructor for a new tuple comparer

CompositeComparer<T1, T2, T3>(IComparer<T1> comparer1, IComparer<T2> comparer2, IComparer<T3> comparer3)

Constructor for a new tuple comparer

CompositeComparer<T1, T2, T3>(int offset, IComparer<T1> comparer1, IComparer<T2> comparer2, IComparer<T3> comparer3)

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 type
  • comparer2 — Comparer for the second element type
  • comparer3 — Comparer for the third 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)

Comparer3

IComparer<T3> Comparer3 { get; }

Comparer for the third element (at position Offset + 2)

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 three items in both tuples

  • x — First tuple
  • y — 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, T3> x, STuple<T1, T2, T3> y)

Compare two tuples

  • x — First tuple
  • y — 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, T3) x, (T1, T2, T3) y)

Compare two tuples

  • x — First tuple
  • y — 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