using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace System { [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", Scope = "type")] public static class Tuple { public static Tuple Create(Ta a, Tb b) { return new Tuple(a, b); } public static Tuple Create(Ta a, Tb b, Tc c) { return new Tuple(a, b, c); } public static T Assign(this Tuple tuple, Func f) { return f(tuple.A, tuple.B); } } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", Scope = "type")] public struct Tuple { public Tuple(Ta a, Tb b) { this.a = a; this.b = b; } readonly Ta a; public Ta A { get { return this.a; } } readonly Tb b; public Tb B { get { return this.b; } } public static bool operator ==(Tuple tup1, Tuple tup2) { return Object.Equals(tup1.A, tup2.A) && Object.Equals(tup1.B, tup2.B); } public static bool operator !=(Tuple tup1, Tuple tup2) { return !(tup1 == tup2); } public override bool Equals(object obj) { if (obj is Tuple) return this == (Tuple)obj; else return false; } public override int GetHashCode() { return this.A.GetHashCode() ^ this.B.GetHashCode(); } } public struct Tuple { public Tuple(Ta a, Tb b, Tc c) { this.a = a; this.b = b; this.c = c; } readonly Ta a; public Ta A { get { return this.a; } } readonly Tb b; public Tb B { get { return this.b; } } readonly Tc c; public Tc C { get { return this.c; } } public static bool operator ==(Tuple tup1, Tuple tup2) { return Object.Equals(tup1.A, tup2.A) && Object.Equals(tup1.B, tup2.B) && Object.Equals(tup1.C, tup2.C); } public static bool operator !=(Tuple tup1, Tuple tup2) { return !(tup1 == tup2); } public override bool Equals(object obj) { if (obj is Tuple) return this == (Tuple)obj; else return false; } public override int GetHashCode() { return this.A.GetHashCode() ^ this.B.GetHashCode() ^ this.C.GetHashCode(); } } }