STuple<T1, T2, T3>
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, T2, T3>>, IComparable<STuple<T1, T2, T3>>, IEquatable<(T1, T2, T3)>, IComparable<(T1, T2, T3)>, IComparable, ITupleSpanPackable, ITuplePackable, ITupleFormattable, ISpanFormattable, ISpanEncodable
Tuple that can hold three items
Constructors
STuple<T1, T2, T3>
STuple<T1, T2, T3>(T1 item1, T2 item2, T3 item3)
Constructs a STuple
Properties
Count
int Count { get; }
Item
object Item { get; }
IVarTuple Item { get; }
IVarTuple Item { get; }
Last
T3 Last { get; }
Return the value of the last item in the tuple
Tail
STuple<T2, T3> Tail { get; }
Return a tuple without the first item
Methods
Append
STuple<T1, T2, T3, T4> Append<T4>(T4 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, IVarTuple> Append(IVarTuple value)
Copy all the items of this tuple into an array at the specified offset
STuple<T1, T2, T3, T4, T5> Append<T4, T5>(T4 value1, T5 value2)
Appends two new items at the end of the current tuple.
value1— First item that will be added as an embedded itemvalue2— Second item that will be added as an embedded item
Returns: New tuple with two 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, T2, T3> other)
int CompareTo((T1, T2, T3) 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, T3, T4> Concat<T4>(STuple<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> Concat<T4>((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<T4, T5>(STuple<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> Concat<T4, T5>((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<T4, T5, T6>(STuple<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> Concat<T4, T5, T6>((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<T4, T5, T6, T7>(STuple<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> Concat<T4, T5, T6, T7>((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<T4, T5, T6, T7, T8>(STuple<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
STuple<T1, T2, T3, T4, T5, T6, T7, T8> Concat<T4, T5, T6, T7, T8>((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)
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);
Deconstruct
void Deconstruct(out T1 item1, out T2 item2, out T3 item3)
Equals
bool Equals(object obj)
bool Equals(IVarTuple other)
bool Equals(STuple<T1, T2, T3> other)
bool Equals((T1, T2, T3) other)
Fill
void Fill(ref (T1, T2, T3) 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, T2, T3) ToValueTuple()
TryFormat
bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format = null, IFormatProvider provider = null)
With
void With(Action<T1, T2, T3> 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, T2, T3, 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 element of the triplet
Item2
readonly T2 Item2
Second element of the triplet
Item3
readonly T3 Item3
Third and last element of the triplet