using System;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Runtime.CompilerServices;
namespace System {
///
/// Helper so we can call some tuple methods recursively without knowing the underlying types.
///
internal interface ITupleInternal : ITuple {
string ToString(StringBuilder sb);
int GetHashCode(IEqualityComparer comparer);
}
public static class Tuple {
public static Tuple Create(T1 item1) {
return new Tuple(item1);
}
public static Tuple Create(T1 item1, T2 item2) {
return new Tuple(item1, item2);
}
public static Tuple Create(T1 item1, T2 item2, T3 item3) {
return new Tuple(item1, item2, item3);
}
public static Tuple Create(T1 item1, T2 item2, T3 item3, T4 item4) {
return new Tuple(item1, item2, item3, item4);
}
public static Tuple Create(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5) {
return new Tuple(item1, item2, item3, item4, item5);
}
public static Tuple Create(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6) {
return new Tuple(item1, item2, item3, item4, item5, item6);
}
public static Tuple Create(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6, T7 item7) {
return new Tuple(item1, item2, item3, item4, item5, item6, item7);
}
public static Tuple> Create(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6, T7 item7, T8 item8) {
return new Tuple>(item1, item2, item3, item4, item5, item6, item7, new Tuple(item8));
}
// From System.Web.Util.HashCodeCombiner
internal static int CombineHashCodes(int h1, int h2)
{
return (((h1 << 5) + h1) ^ h2);
}
internal static int CombineHashCodes(int h1, int h2, int h3) {
return CombineHashCodes(CombineHashCodes(h1, h2), h3);
}
internal static int CombineHashCodes(int h1, int h2, int h3, int h4) {
return CombineHashCodes(CombineHashCodes(h1, h2), CombineHashCodes(h3, h4));
}
internal static int CombineHashCodes(int h1, int h2, int h3, int h4, int h5) {
return CombineHashCodes(CombineHashCodes(h1, h2, h3, h4), h5);
}
internal static int CombineHashCodes(int h1, int h2, int h3, int h4, int h5, int h6) {
return CombineHashCodes(CombineHashCodes(h1, h2, h3, h4), CombineHashCodes(h5, h6));
}
internal static int CombineHashCodes(int h1, int h2, int h3, int h4, int h5, int h6, int h7) {
return CombineHashCodes(CombineHashCodes(h1, h2, h3, h4), CombineHashCodes(h5, h6, h7));
}
internal static int CombineHashCodes(int h1, int h2, int h3, int h4, int h5, int h6, int h7, int h8) {
return CombineHashCodes(CombineHashCodes(h1, h2, h3, h4), CombineHashCodes(h5, h6, h7, h8));
}
}
[Serializable]
public class Tuple : IStructuralEquatable, IStructuralComparable, IComparable, ITupleInternal, ITuple {
private readonly T1 m_Item1;
public T1 Item1 { get { return m_Item1; } }
public Tuple(T1 item1) {
m_Item1 = item1;
}
public override Boolean Equals(Object obj) {
return ((IStructuralEquatable) this).Equals(obj, EqualityComparer