2010-05-13 Rodrigo Kumpera <rkumpera@novell.com>
[mono-project.git] / mcs / tests / gtest-112.cs
blob47ebf9ebeef4451d4b0baa4bc32260b76e7f1452
1 using System;
3 public interface IComparer<T>
5 void Compare (T a);
8 class IC : IComparer<Foo<int>>
10 public void Compare (Foo<int> a)
11 { }
14 public struct Foo<K>
16 public K Value;
18 public Foo (K value)
20 Value = value;
24 public class List<T>
26 public virtual void Sort (IComparer<T> c, T t)
28 Sorting.IntroSort<T> (c, t);
32 public class Sorting
34 public static void IntroSort<T> (IComparer<T> c, T t)
36 new Sorter<T> (c, 4, t).InsertionSort (0);
39 class Sorter<T>
41 IComparer<T> c;
42 T[] a;
44 public Sorter (IComparer<T> c, int size, T item)
46 this.c = c;
47 a = new T [size];
50 internal void InsertionSort (int i)
52 T other;
53 c.Compare (other = a[i]);
58 class X
60 static void Main ()
62 List<Foo<int>> list = new List<Foo<int>> ();
63 Foo<int> foo = new Foo<int> (3);
64 list.Sort (new IC (), foo);