Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mcs / tests / gtest-112.cs
1 using System;
2
3 public interface IComparer<T>
4 {
5         void Compare (T a);
6 }
7
8 class IC : IComparer<Foo<int>>
9 {
10         public void Compare (Foo<int> a)
11         { }
12 }
13
14 public struct Foo<K>
15 {
16         public K Value;
17
18         public Foo (K value)
19         {
20                 Value = value;
21         }
22 }
23
24 public class List<T>
25 {
26         public virtual void Sort (IComparer<T> c, T t)
27         {
28                 Sorting.IntroSort<T> (c, t);
29         }
30 }
31
32 public class Sorting
33 {
34         public static void IntroSort<T> (IComparer<T> c, T t)
35         {
36                 new Sorter<T> (c, 4, t).InsertionSort (0);
37         }
38
39         class Sorter<T>
40         {
41                 IComparer<T> c;
42                 T[] a;
43
44                 public Sorter (IComparer<T> c, int size, T item)
45                 {
46                         this.c = c;
47                         a = new T [size];
48                 }
49
50                 internal void InsertionSort (int i)
51                 {
52                         T other;
53                         c.Compare (other = a[i]);
54                 }
55         }
56 }
57
58 class X
59 {
60         public static void Main ()
61         {
62                 List<Foo<int>> list = new List<Foo<int>> ();
63                 Foo<int> foo = new Foo<int> (3);
64                 list.Sort (new IC (), foo);
65         }
66 }