Example #1
0
        public async Task RunQuickSortAscending(int amount)
        {
            SortFactory             factory        = new SortFactory();
            ISortable               sortable       = factory.GetSortable(Algorithm.QuickSort);
            IGeneratorItems         generatorItems = new AscendingGenerator();
            CancellationTokenSource cts            = new CancellationTokenSource();

            var p = new Progress <SortingCore.Services.TimeWatchSortable.TimeAndValue>(async m =>
            {
                await _hubContext.Clients.All.ReceiveProgressAscSortQuick(m.time, m.value);
            });

            await Sort(sortable, generatorItems, amount, p, cts);
        }
Example #2
0
        static void Main(string[] args)
        {
            //TODO:
            //la copia del array no hacerla aca, aunque revisar como se comporta con gran cantidad de datos: uso de memoria
            //implementar un Comparable en el core
            //Incluir el llamado tambn a random y ordenarlo.
            //Incluir Signal R para realizar una grafica en el front (y sea el back el q envia los datos)
            //https://docs.microsoft.com/en-us/aspnet/core/fundamentals/websockets?view=aspnetcore-2.1
            //desacoplar del hub el llamado directo a los sort y demas.
            //para las graficas agregar la del insert y en una sola grafica poder mostrar las 3 comparaciones.
            //el back devuelva cuando termina de ordenar, de esa forma se puede hacer el clean del interval

            SortFactory factory           = new SortFactory();
            ISortable   sortable          = factory.GetSortable(Algorithm.BubbleSort);
            ISortable   sortableSelection = factory.GetSortable(Algorithm.SelectionSort);
            ISortable   sortableInsertion = factory.GetSortable(Algorithm.InsertionSort);
            ISortable   sortableShell     = factory.GetSortable(Algorithm.ShellSort);
            ISortable   sortableQuick     = factory.GetSortable(Algorithm.QuickSort);
            ISortable   sortableMerge     = factory.GetSortable(Algorithm.MergeSort);

            IGeneratorItems generatorItems = new AscendingGenerator();

            List <int> iterations = new List <int>();

            iterations.Add(10000);
            //iterations.Add(100000);
            //iterations.Add(1000000);
            //iterations.Add(10000000);
            FileService fileService = new FileService();

            fileService.Delete(path);
            foreach (int iteration in iterations)
            {
                Sort(sortable, generatorItems, iteration, fileService);
                Sort(sortableSelection, generatorItems, iteration, fileService);
                Sort(sortableInsertion, generatorItems, iteration, fileService);
                Sort(sortableShell, generatorItems, iteration, fileService);
                Sort(sortableQuick, generatorItems, iteration, fileService);
                Sort(sortableMerge, generatorItems, iteration, fileService);
            }

            Console.ReadKey();
        }