/// <summary>Gets an enumerator for a tuple.</summary> /// <param name="tuple">The tuple to get an enumerator for.</param> /// <returns>An enumerator for a tuple.</returns> public static System.Collections.Generic.IEnumerator <object> GetEnumerator(this System.Runtime.CompilerServices.ITuple tuple) { for (int i = 0; i < tuple.Length; i++) { yield return(tuple[i]); } }
public static double HMean(this System.Runtime.CompilerServices.ITuple values) { double mean = 0; for (int i = 0; i < values.Length; i++) { mean += (double)values[i]; } mean /= values.Length; return(mean); }
//protected static string _ToString2<T, U>(string format, KeyValuePair<T, U> obj, string[] delims) //{ // HDebug.Assert(delims.Length == 3); // StringBuilder text = new StringBuilder(); // text.Append(delims[0]); // text.Append(_ToString2(format, obj.Key)); // text.Append(delims[1]); // text.Append(_ToString2(format, obj.Value)); // text.Append(delims[2]); // return text.ToString(); //} protected static void _ToString2(StringBuilder text, string format, System.Runtime.CompilerServices.ITuple obj) { int leng = obj.Length; object[] objs = new object[leng]; for (int i = 0; i < leng; i++) { objs[i] = obj[i]; } _ToString2(text, format, objs); }
protected static string _ToString(string format, System.Runtime.CompilerServices.ITuple obj) { int leng = obj.Length; object[] objs = new object[leng]; for (int i = 0; i < leng; i++) { objs[i] = obj[i]; } return(_ToString(format, objs)); }
internal string GetHashForObject(object?value) { var c = System.Globalization.CultureInfo.InvariantCulture; return(this.GetHashForString(value switch { string s => s, int i => i.ToString(c), long l => l.ToString(c), uint i => i.ToString(c), ulong l => l.ToString(c), byte b => b.ToString(c), bool b => b.ToString(c), null => "", System.Runtime.CompilerServices.ITuple tuple => TupleToString(tuple), System.Collections.IEnumerable enumerable => EnumberableToString(enumerable), _ => this.GetStringForObject(value) }));;;