using My.Collections;
using System;
using System.Diagnostics;

namespace Sort;

class Program
{
    private delegate void Delegates();

    static void Main()
    {
        var list = new SortedArrayList<int>();

        list.AddRange(new int[] { 9, 4, 8, 7, 6, 4, 2, 9, 4, 5 });
        list.BucketSort();
        Console.WriteLine(list);

        Delegates[] funcs = new Delegates[]
                        {
                               new Delegates(list.BubbleSort),
                               new Delegates(list.InsertionSort),
                               new Delegates(list.QuickSort),
                               new Delegates(list.BucketSort),
                               new Delegates(list.MergeSort)
                        };

        var w = new Stopwatch();

        foreach (var func in funcs)
        {
            list.AddRange(new int[] { 8, 7, 3, 5, 9, 4, 1 });

            w.Restart();
            func();
            w.Stop();

            Console.WriteLine(func.Method.ToString() + ": " + list.ToString());
            Console.WriteLine(w.ElapsedTicks);
            list.Clear();
        }
        Console.ReadLine();
    }
}