JoinedTuple<THead, TTail>

Namespace: SnowBank.Data.Tuples · class

Implements: IVarTuple, IEquatable<IVarTuple>, IComparable<IVarTuple>, IReadOnlyList<object>, IEnumerable<object>, IEnumerable, IReadOnlyCollection<object>, IStructuralEquatable, IStructuralComparable, ITuple, IFormattable, IComparable, ITupleFormattable

Tuple that represents the concatenation of two tuples

Constructors

JoinedTuple<THead, TTail>

JoinedTuple<THead, TTail>(THead head, TTail tail)

Properties

Count

int Count { get; }

Item

object Item { get; }

IVarTuple Item { get; }

object Item { get; }

IVarTuple Item { get; }

Methods

Append

LinkedTuple<T> Append<T>(T 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")

CompareTo

int CompareTo(IVarTuple other)

int CompareTo(object other)

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);

Equals

bool Equals(object obj)

bool Equals(IVarTuple other)

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"

GetEnumerator

IEnumerator<object> GetEnumerator()

GetFirst

T GetFirst<T>()

Returns the type value of the first item of the tuple

GetHashCode

int GetHashCode()

GetLast

T GetLast<T>()

Returns the type value of the last item of the tuple

ToString

string ToString()

Returns a human-readable representation of this tuple

string ToString(string format, IFormatProvider provider = null)

Returns a human-readable representation of this tuple

Fields

readonly THead Head

First tuple (first N items)

Tail

readonly TTail Tail

Second tuple (last M items)