"disable_omit_fp" can now be included in MONO_DEBUG
[mono-project.git] / mcs / tests / gtest-197.cs
blobe1ce88fcb34c7421651cb10820007e400b176302
1 using System;
2 using System.Runtime.InteropServices;
4 namespace Martin.Collections.Generic {
5 [Serializable]
6 public abstract class EqualityComparer <T> : IEqualityComparer <T> {
8 static EqualityComparer ()
10 if (typeof (IEquatable <T>).IsAssignableFrom (typeof (T)))
11 _default = (EqualityComparer <T>) Activator.CreateInstance (typeof (IEquatableOfTEqualityComparer<>).MakeGenericType (typeof (T)));
12 else
13 _default = new DefaultComparer ();
17 public abstract int GetHashCode (T obj);
18 public abstract bool Equals (T x, T y);
20 static readonly EqualityComparer <T> _default;
22 public static EqualityComparer <T> Default {
23 get {
24 return _default;
28 [Serializable]
29 class DefaultComparer : EqualityComparer<T> {
31 public override int GetHashCode (T obj)
33 return obj.GetHashCode ();
36 public override bool Equals (T x, T y)
38 if (x == null)
39 return y == null;
41 return x.Equals (y);
46 [Serializable]
47 class IEquatableOfTEqualityComparer <T> : EqualityComparer <T> where T : IEquatable <T> {
49 public override int GetHashCode (T obj)
51 return obj.GetHashCode ();
54 public override bool Equals (T x, T y)
56 if (x == null)
57 return y == null;
59 return x.Equals (y);
63 public interface IEqualityComparer<T> {
64 bool Equals (T x, T y);
65 int GetHashCode (T obj);
68 class X
70 public static void Main ()
71 { }