IVarTuple
Namespace: SnowBank.Data.Tuples · interface
Implements: IEquatable<IVarTuple>, IComparable<IVarTuple>, IReadOnlyList<object>, IEnumerable<object>, IEnumerable, IReadOnlyCollection<object>, IStructuralEquatable, IStructuralComparable, ITuple, IFormattable
Represents a Tuple of variable length and elements of different types
Properties
Item
object Item { get; }
IVarTuple Item { get; }
object Item { get; }
IVarTuple Item { get; }
Methods
Append
IVarTuple Append<TItem>(TItem value)
Returns a new Tuple by that contains the element of this tuple, with an extra item at the end
value— Value of the item that will be appended at the end
Returns: New tuple with the extra item
If TItem is an IVarTuple, then it will be appended as a single element. If you need to append the items of a tuple, you must call Concat
Example: STuple.Create("Hello").Append("World") => ("Hello", "World")
Concat
IVarTuple Concat(IVarTuple tuple)
Returns a new Tuple by appending the items of another tuple at the end of this tuple
tuple— Tuple whose items must be appended at the end of the current tuple
Returns: New tuple, or the same instance if tuple is empty.
CopyTo
void CopyTo(object[] array, int offset)
Copies all items of the tuple into an array at a specific location.
array— The destination array, which must be large enough to contain all the items.offset— The offset at which to start copying items.
var tmp = new object[3];
("Hello", "World", 123).CopyTo(tmp, 0);
Get
TItem Get<TItem>(int index)
Returns the typed value of an item of the tuple, given its position
index— Position of the item
Returns: Value of the item at position index, adapted into type TItem.
STuple.Create("Hello", "World", 123,).Get<string>(0) => "Hello"STuple.Create("Hello", "World", 123,).Get<int>(2) => 123STuple.Create("Hello", "World", 123,).Get<string>(2) => "123"
TItem Get<TItem>(Index index)
Returns the typed value of an item of the tuple, given its position
index— Position of the item
Returns: Value of the item at position index, adapted into type TItem.
STuple.Create("Hello", "World", 123,).Get<string>(0) => "Hello"STuple.Create("Hello", "World", 123,).Get<int>(^1) => 123STuple.Create("Hello", "World", 123,).Get<string>(^1) => "123"
GetFirst
TItem GetFirst<TItem>()
Returns the type value of the first item of the tuple
GetItemHashCode
int GetItemHashCode(int index, IEqualityComparer comparer)
Computes a stable hash code for the item at the specific location
GetLast
TItem GetLast<TItem>()
Returns the type value of the last item of the tuple