ListTuple<T>

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 can hold any number of untyped items

Constructors

ListTuple<T>

ListTuple<T>(IEnumerable<T> items)

Create a new tuple from a sequence of items (copied)

ListTuple<T>(T[] items)

ListTuple<T>(ReadOnlyMemory<T> items)

Wrap a List of items

The list should not mutate and should not be exposed to anyone else!

ListTuple<T>(ListTuple<T> a, ListTuple<T> b)

Create a new list tuple by merging the items of two tuples together

ListTuple<T>(T[] items, int offset, int count)

ListTuple<T>(ListTuple<T> a, ListTuple<T> b, ListTuple<T> c)

Create a new list tuple by merging the items of three tuples together

Properties

Count

int Count { get; }

Item

T Item { get; }

IVarTuple Item { get; }

T 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")

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(T[] array, int offset)

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<T> GetEnumerator()

GetFirst

TItem GetFirst<TItem>()

Returns the type value of the first item of the tuple

GetHashCode

int GetHashCode()

GetLast

TItem GetLast<TItem>()

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