STuple<T1>

Namespace: SnowBank.Data.Tuples · struct

Implements: IVarTuple, IEquatable<IVarTuple>, IComparable<IVarTuple>, IReadOnlyList<object>, IEnumerable<object>, IEnumerable, IReadOnlyCollection<object>, IStructuralEquatable, IStructuralComparable, ITuple, IFormattable, IEquatable<STuple<T1>>, IComparable<STuple<T1>>, IEquatable<(T1)>, IComparable<(T1)>, IComparable, ITupleFormattable, ITupleSpanPackable, ITuplePackable, ISpanFormattable, ISpanEncodable

Tuple that holds only one item

Constructors

STuple<T1>

STuple<T1>(T1 item1)

Constructs a STuple

Properties

Count

int Count { get; }

Item

object Item { get; }

IVarTuple Item { get; }

IVarTuple Item { get; }

Methods

Append

STuple<T1, T2> Append<T2>(T2 value)

Appends a single new item at the end of the current tuple.

  • value — Value that will be added as an embedded item

Returns: New tuple with one extra item

If is a tuple, and you want to append the items of this tuple, and not the tuple itself, please call !

STuple<T1, T2, T3> Append<T2, T3>(T2 value1, T3 value2)

Appends two new items at the end of the current tuple.

  • value1 — First item that will be added as an embedded item
  • value2 — Second item that will be added as an embedded item

Returns: New tuple with one extra item

If any of or is a tuple, and you want to append the items of this tuple, and not the tuple itself, please call !

CompareTo

int CompareTo(STuple<T1> other)

int CompareTo((T1) other)

int CompareTo(IVarTuple other)

Concat

IVarTuple Concat(IVarTuple tuple)

Appends the items of a tuple at the end of the current tuple.

  • tuple — Tuple whose items are to be appended at the end

Returns: New tuple composed of the current tuple items, followed by tuple's items

STuple<T1, T2> Concat<T2>(STuple<T2> tuple)

STuple<T1, T2, T3> Concat<T2, T3>(STuple<T2, T3> tuple)

STuple<T1, T2, T3, T4> Concat<T2, T3, T4>(STuple<T2, T3, T4> tuple)

STuple<T1, T2> Concat<T2>((T2) tuple)

Appends the items of a tuple at the end of the current tuple.

  • tuple — Tuple whose items are to be appended at the end

Returns: New tuple composed of the current tuple items, followed by tuple's items

STuple<T1, T2, T3> Concat<T2, T3>((T2, T3) tuple)

Appends the items of a tuple at the end of the current tuple.

  • tuple — Tuple whose items are to be appended at the end

Returns: New tuple composed of the current tuple items, followed by tuple's items

STuple<T1, T2, T3, T4> Concat<T2, T3, T4>((T2, T3, T4) tuple)

Appends the items of a tuple at the end of the current tuple.

  • tuple — Tuple whose items are to be appended at the end

Returns: New tuple composed of the current tuple items, followed by tuple's items

STuple<T1, T2, T3, T4, T5> Concat<T2, T3, T4, T5>((T2, T3, T4, T5) tuple)

Appends the items of a tuple at the end of the current tuple.

  • tuple — Tuple whose items are to be appended at the end

Returns: New tuple composed of the current tuple items, followed by tuple's items

STuple<T1, T2, T3, T4, T5, T6> Concat<T2, T3, T4, T5, T6>((T2, T3, T4, T5, T6) tuple)

Appends the items of a tuple at the end of the current tuple.

  • tuple — Tuple whose items are to be appended at the end

Returns: New tuple composed of the current tuple items, followed by tuple's items

STuple<T1, T2, T3, T4, T5, T6, T7> Concat<T2, T3, T4, T5, T6, T7>((T2, T3, T4, T5, T6, T7) tuple)

Appends the items of a tuple at the end of the current tuple.

  • tuple — Tuple whose items are to be appended at the end

Returns: New tuple composed of the current tuple items, followed by tuple's items

STuple<T1, T2, T3, T4, T5, T6, T7, T8> Concat<T2, T3, T4, T5, T6, T7, T8>((T2, T3, T4, T5, T6, T7, T8) tuple)

Appends the items of a tuple at the end of the current tuple.

  • tuple — Tuple whose items are to be appended at the end

Returns: New tuple composed of the current tuple items, followed by tuple's items

CopyTo

void CopyTo(object[] array, int offset)

Copy the item of this singleton into an array at the specified offset

Deconstruct

void Deconstruct(out T1 item1)

Equals

bool Equals(object obj)

bool Equals(IVarTuple other)

bool Equals(STuple<T1> other)

bool Equals((T1) other)

Fill

void Fill(ref (T1) t)

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

GetHashCode

int GetHashCode()

ToString

string ToString()

string ToString(string format, IFormatProvider provider = null)

ToValueTuple

(T1) ToValueTuple()

TryFormat

bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format = null, IFormatProvider provider = null)

With

void With(Action<T1> lambda)

Execute a lambda Action with the content of this tuple

  • lambda — Action that will be passed the content of this tuple as parameters

TItem With<TItem>(Func<T1, TItem> lambda)

Execute a lambda Function with the content of this tuple

  • lambda — Action that will be passed the content of this tuple as parameters

Returns: Result of calling lambda with the items of this tuple

Fields

Item1

readonly T1 Item1

First and only item in the tuple