Jo Shields a575963da9 Imported Upstream version 3.6.0
Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
2014-08-13 10:39:27 +01:00

67 lines
871 B
C#

using System;
public interface IComparer<T>
{
void Compare (T a);
}
class IC : IComparer<Foo<int>>
{
public void Compare (Foo<int> a)
{ }
}
public struct Foo<K>
{
public K Value;
public Foo (K value)
{
Value = value;
}
}
public class List<T>
{
public virtual void Sort (IComparer<T> c, T t)
{
Sorting.IntroSort<T> (c, t);
}
}
public class Sorting
{
public static void IntroSort<T> (IComparer<T> c, T t)
{
new Sorter<T> (c, 4, t).InsertionSort (0);
}
class Sorter<T>
{
IComparer<T> c;
T[] a;
public Sorter (IComparer<T> c, int size, T item)
{
this.c = c;
a = new T [size];
}
internal void InsertionSort (int i)
{
T other;
c.Compare (other = a[i]);
}
}
}
class X
{
public static void Main ()
{
List<Foo<int>> list = new List<Foo<int>> ();
Foo<int> foo = new Foo<int> (3);
list.Sort (new IC (), foo);
}
}