LinkedTuple<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 adds a value at the end of an already existing tuple
Constructors
LinkedTuple<T>
LinkedTuple<T>(IVarTuple head, T tail)
Append a new value at the end of an existing tuple
Properties
Count
int Count { get; }
Returns the number of elements in this tuple
Item
object Item { get; }
IVarTuple Item { get; }
object Item { get; }
IVarTuple Item { get; }
Last
T Last { 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(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
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
Fields
Head
readonly IVarTuple Head
Link to the parent tuple that contains the head.
Tail
readonly T Tail
Value of the last element of the tuple