TupleHelpers
Namespace: SnowBank.Data.Tuples · class
Helpers for writing custom IVarTuple implementations
Methods
Compare
static int Compare<TTuple>(TTuple left, object other, IComparer comparer)
static int Compare<TTuple>(in TTuple left, object other, IComparer comparer)
static int Compare<TTuple>(TTuple x, IVarTuple y, IComparer comparer)
static int Compare<TTuple>(in TTuple x, IVarTuple y, IComparer comparer)
static int Compare<TTuple>(TTuple x, ITuple y, IComparer comparer)
static int Compare<TTuple>(in TTuple x, ITuple y, IComparer comparer)
CopyTo
static int CopyTo(IVarTuple tuple, object[] array, int offset)
Helper to copy the content of a tuple at a specific position in an array
Returns: Updated offset just after the last element of the copied tuple
EndsWith
static bool EndsWith(IVarTuple a, IVarTuple b)
Default (non-optimized) implementation for ITuple.EndsWith()
a— Larger tupleb— Smaller tuple
Returns: True if a starts with (or is equal to) b
Equals
static bool Equals<TTuple>(TTuple left, object other, IEqualityComparer comparer)
static bool Equals<TTuple>(in TTuple left, object other, IEqualityComparer comparer)
static bool Equals<TTuple>(TTuple x, IVarTuple y, IEqualityComparer comparer)
static bool Equals<TTuple>(in TTuple x, IVarTuple y, IEqualityComparer comparer)
static bool Equals<TTuple>(TTuple x, ITuple y, IEqualityComparer comparer)
static bool Equals<TTuple>(in TTuple x, ITuple y, IEqualityComparer comparer)
FailIndexOutOfRange
static T FailIndexOutOfRange<T>(int index, int count)
static T FailIndexOutOfRange<T>(Index index, int count)
FailTupleIsEmpty
static InvalidOperationException FailTupleIsEmpty()
MapIndex
static int MapIndex(int index, int count)
Maps a relative index into an absolute index
index— Relative index in the tuple (from the end if negative)count— Size of the tuple
Returns: Absolute index from the start of the tuple, or exception if outside the tuple
static int MapIndex(Index index, int count)
Maps a relative index into an absolute index
index— Relative index in the tuple (from the end if negative)count— Size of the tuple
Returns: Absolute index from the start of the tuple, or exception if outside the tuple
MapIndexBounded
static int MapIndexBounded(int index, int count)
Maps a relative index into an absolute index
index— Relative index in the tuple (from the end if negative)count— Size of the tuple
Returns: Absolute index from the start of the tuple. Truncated to 0 if index is before the start of the tuple, or to count if the index is after the end of the tuple
Splice
static IVarTuple Splice(IVarTuple tuple, Range range)
Default (non-optimized) implementation of ITuple.this[Range]
tuple— Tuple to slicerange— Range to select
Returns: New tuple only containing items inside this section
static IVarTuple Splice(IVarTuple tuple, int? fromIncluded, int? toExcluded)
Default (non-optimized) implementation of ITuple.this[long?, long?]
tuple— Tuple to slicefromIncluded— Start offset of the section (included)toExcluded— End offset of the section (included)
Returns: New tuple only containing items inside this section
StartsWith
static bool StartsWith(IVarTuple a, IVarTuple b)
Default (non-optimized) implementation for ITuple.StartsWith()
a— Larger tupleb— Smaller tuple
Returns: True if a starts with (or is equal to) b
StructuralCompare
static int StructuralCompare(IVarTuple x, IVarTuple y, IComparer comparer)
StructuralGetHashCode
static int StructuralGetHashCode(IVarTuple tuple, IEqualityComparer comparer)
ThrowTupleIsEmpty
static void ThrowTupleIsEmpty()