return ((IStructuralComparable) this).CompareTo (obj, Comparer<object>.Default);
}
- [MonoTODO] int IStructuralComparable.CompareTo (object other, IComparer comparer)
+ int IStructuralComparable.CompareTo (object other, IComparer comparer)
{
- throw new NotImplementedException ();
+ var t = other as Tuple<T1>;
+ if (t == null) {
+ if (other == null) return 1;
+ throw new ArgumentException ();
+ }
+
+ return comparer.Compare (item1, t.item1);
}
public override bool Equals (object obj)
return ((IStructuralComparable) this).CompareTo (obj, Comparer<object>.Default);
}
- [MonoTODO] int IStructuralComparable.CompareTo (object other, IComparer comparer)
+ int IStructuralComparable.CompareTo (object other, IComparer comparer)
{
- throw new NotImplementedException ();
+ var t = other as Tuple<T1, T2>;
+ if (t == null) {
+ if (other == null) return 1;
+ throw new ArgumentException ();
+ }
+
+ int res = comparer.Compare (item1, t.item1);
+ if (res != 0) return res;
+ return comparer.Compare (item2, t.item2);
}
public override bool Equals (object obj)
return ((IStructuralComparable) this).CompareTo (obj, Comparer<object>.Default);
}
- [MonoTODO] int IStructuralComparable.CompareTo (object other, IComparer comparer)
+ int IStructuralComparable.CompareTo (object other, IComparer comparer)
{
- throw new NotImplementedException ();
+ var t = other as Tuple<T1, T2, T3>;
+ if (t == null) {
+ if (other == null) return 1;
+ throw new ArgumentException ();
+ }
+
+ int res = comparer.Compare (item1, t.item1);
+ if (res != 0) return res;
+ res = comparer.Compare (item2, t.item2);
+ if (res != 0) return res;
+ return comparer.Compare (item3, t.item3);
}
public override bool Equals (object obj)
return ((IStructuralComparable) this).CompareTo (obj, Comparer<object>.Default);
}
- [MonoTODO] int IStructuralComparable.CompareTo (object other, IComparer comparer)
+ int IStructuralComparable.CompareTo (object other, IComparer comparer)
{
- throw new NotImplementedException ();
+ var t = other as Tuple<T1, T2, T3, T4>;
+ if (t == null) {
+ if (other == null) return 1;
+ throw new ArgumentException ();
+ }
+
+ int res = comparer.Compare (item1, t.item1);
+ if (res != 0) return res;
+ res = comparer.Compare (item2, t.item2);
+ if (res != 0) return res;
+ res = comparer.Compare (item3, t.item3);
+ if (res != 0) return res;
+ return comparer.Compare (item4, t.item4);
}
public override bool Equals (object obj)
return ((IStructuralComparable) this).CompareTo (obj, Comparer<object>.Default);
}
- [MonoTODO] int IStructuralComparable.CompareTo (object other, IComparer comparer)
+ int IStructuralComparable.CompareTo (object other, IComparer comparer)
{
- throw new NotImplementedException ();
+ var t = other as Tuple<T1, T2, T3, T4, T5>;
+ if (t == null) {
+ if (other == null) return 1;
+ throw new ArgumentException ();
+ }
+
+ int res = comparer.Compare (item1, t.item1);
+ if (res != 0) return res;
+ res = comparer.Compare (item2, t.item2);
+ if (res != 0) return res;
+ res = comparer.Compare (item3, t.item3);
+ if (res != 0) return res;
+ res = comparer.Compare (item4, t.item4);
+ if (res != 0) return res;
+ return comparer.Compare (item5, t.item5);
}
public override bool Equals (object obj)
return ((IStructuralComparable) this).CompareTo (obj, Comparer<object>.Default);
}
- [MonoTODO] int IStructuralComparable.CompareTo (object other, IComparer comparer)
+ int IStructuralComparable.CompareTo (object other, IComparer comparer)
{
- throw new NotImplementedException ();
+ var t = other as Tuple<T1, T2, T3, T4, T5, T6>;
+ if (t == null) {
+ if (other == null) return 1;
+ throw new ArgumentException ();
+ }
+
+ int res = comparer.Compare (item1, t.item1);
+ if (res != 0) return res;
+ res = comparer.Compare (item2, t.item2);
+ if (res != 0) return res;
+ res = comparer.Compare (item3, t.item3);
+ if (res != 0) return res;
+ res = comparer.Compare (item4, t.item4);
+ if (res != 0) return res;
+ res = comparer.Compare (item5, t.item5);
+ if (res != 0) return res;
+ return comparer.Compare (item6, t.item6);
}
public override bool Equals (object obj)
return ((IStructuralComparable) this).CompareTo (obj, Comparer<object>.Default);
}
- [MonoTODO] int IStructuralComparable.CompareTo (object other, IComparer comparer)
+ int IStructuralComparable.CompareTo (object other, IComparer comparer)
{
- throw new NotImplementedException ();
+ var t = other as Tuple<T1, T2, T3, T4, T5, T6, T7>;
+ if (t == null) {
+ if (other == null) return 1;
+ throw new ArgumentException ();
+ }
+
+ int res = comparer.Compare (item1, t.item1);
+ if (res != 0) return res;
+ res = comparer.Compare (item2, t.item2);
+ if (res != 0) return res;
+ res = comparer.Compare (item3, t.item3);
+ if (res != 0) return res;
+ res = comparer.Compare (item4, t.item4);
+ if (res != 0) return res;
+ res = comparer.Compare (item5, t.item5);
+ if (res != 0) return res;
+ res = comparer.Compare (item6, t.item6);
+ if (res != 0) return res;
+ return comparer.Compare (item7, t.item7);
}
public override bool Equals (object obj)
return ((IStructuralComparable) this).CompareTo (obj, Comparer<object>.Default);
}
- [MonoTODO] int IStructuralComparable.CompareTo (object other, IComparer comparer)
+ int IStructuralComparable.CompareTo (object other, IComparer comparer)
{
- throw new NotImplementedException ();
+ var t = other as Tuple<T1, T2, T3, T4, T5, T6, T7, TRest>;
+ if (t == null) {
+ if (other == null) return 1;
+ throw new ArgumentException ();
+ }
+
+ int res = comparer.Compare (item1, t.item1);
+ if (res != 0) return res;
+ res = comparer.Compare (item2, t.item2);
+ if (res != 0) return res;
+ res = comparer.Compare (item3, t.item3);
+ if (res != 0) return res;
+ res = comparer.Compare (item4, t.item4);
+ if (res != 0) return res;
+ res = comparer.Compare (item5, t.item5);
+ if (res != 0) return res;
+ res = comparer.Compare (item6, t.item6);
+ if (res != 0) return res;
+ res = comparer.Compare (item7, t.item7);
+ if (res != 0) return res;
+ return comparer.Compare (rest, t.rest);
}
public override bool Equals (object obj)
Console.WriteLine ("\t\t}");
Console.WriteLine ();
- Console.WriteLine ("\t\t[MonoTODO] int IStructuralComparable.CompareTo (object other, IComparer comparer)");
+ Console.WriteLine ("\t\tint IStructuralComparable.CompareTo (object other, IComparer comparer)");
Console.WriteLine ("\t\t{");
- Console.WriteLine ("\t\t\tthrow new NotImplementedException ();");
- Console.WriteLine ("\t\t}");
+ Console.WriteLine ("\t\t\tvar t = other as {0};", type_name);
+ Console.WriteLine ("\t\t\tif (t == null) {");
+ Console.WriteLine ("\t\t\t\tif (other == null) return 1;");
+ Console.WriteLine ("\t\t\t\tthrow new ArgumentException ();");
+ Console.WriteLine ("\t\t\t}");
+ Console.WriteLine ();
+
+ for (int i = 1; i < arity; ++i) {
+ Console.Write ("\t\t\t");
+ if (i == 1)
+ Console.Write ("int ");
+
+ Console.WriteLine ("res = comparer.Compare ({0}, t.{0});", GetItemName (i));
+ Console.WriteLine ("\t\t\tif (res != 0) return res;");
+ }
+ Console.WriteLine ("\t\t\treturn comparer.Compare ({0}, t.{0});", GetItemName (arity));
+ Console.WriteLine ("\t\t}");
Console.WriteLine ();
Console.WriteLine ("\t\tpublic override bool Equals (object obj)");
Console.WriteLine ();
Console.WriteLine ("\t\tpublic override int GetHashCode ()");
Console.WriteLine ("\t\t{");
- Console.WriteLine ("\t\t\treturn GetHashCode (EqualityComparer<object>.Default);");
+ Console.WriteLine ("\t\t\treturn ((IStructuralEquatable) this).GetHashCode (EqualityComparer<object>.Default);");
Console.WriteLine ("\t\t}");
Console.WriteLine ();