コード例 #1
0
        private void btnOrdenar_Click(object sender, EventArgs e)
        {
            if (ListaInteiros.Count == 0)
            {
                return;
            }
            int tag = 0;

            foreach (Control r in groupBox1.Controls)
            {
                if (r is RadioButton && ((RadioButton)r).Checked)
                {
                    tag = int.Parse(r.Tag.ToString());
                }
            }

            switch (tag)
            {
            case 1: SelectSort.Sort(ListaInteiros); break;

            case 2: BubbleSort.Sort(ListaInteiros); break;

            case 3: QuickSort.Sort(ListaInteiros);  break;

            case 4: ShellSort.Sort(ListaInteiros);  break;
            }

            CarregaGrid();
        }
コード例 #2
0
        public void SelectSort_UnorderedList_Sorted()
        {
            var result = SelectSort.Sort(new List <int> {
                0, 10, -5, 4, 2, 8
            });

            Assert.Equal(new List <int> {
                -5, 0, 2, 4, 8, 10
            }, result);
        }
コード例 #3
0
        public void SelectSort_ShortList_Sorted()
        {
            var result = SelectSort.Sort(new List <int> {
                10, -10
            });

            Assert.Equal(new List <int> {
                -10, 10
            }, result);
        }
コード例 #4
0
        public void SortTest34()
        {
            int[]      input      = null;
            SelectSort selectsort = new SelectSort(input);

            var result = selectsort.Sort();

            int[] expectResult = null;

            CollectionAssert.AreEqual(input, null);
        }
コード例 #5
0
        public void SortTest22()
        {
            int[]      input      = new int[] { 1, 2, 3, 4, 5 };
            SelectSort selectsort = new SelectSort(input);

            var result = selectsort.Sort();

            int[] expectResult = new int[] { 1, 2, 3, 4, 5 };

            CollectionAssert.AreEqual(input, expectResult);
        }
コード例 #6
0
        private void btnC1_Click(object sender, EventArgs e)
        {
            Ordenado      = true;
            ListaAuxiliar = new List <int>(Lista);
            var t1 = DateTime.Now;

            SelectSort.Sort(ListaAuxiliar);
            var t2 = DateTime.Now;

            label1.Text = "Select Sort = " + (t2 - t1).Milliseconds.ToString() + " ms";
            CarregaGrid(ListaAuxiliar);
            VerificaBloqueiaCalcular();
            btnDesord.Enabled = true;
        }
コード例 #7
0
        static void Main(string[] args)
        {
            var array = new List <int> {
                4, 5, 1, 3, 4, 8, 10
            };
            var   swap     = new SwapService();
            ISort sort     = new SelectSort(swap);
            var   tmpArray = sort.Sort(array);

            for (var i = 0; i < tmpArray.Count; i++)
            {
                Console.WriteLine(tmpArray[i]);
            }

            sort     = new InsertionSort(swap);
            tmpArray = sort.Sort(array);
            for (var i = 0; i < tmpArray.Count; i++)
            {
                Console.WriteLine(tmpArray[i]);
            }

            Console.ReadKey();
        }
コード例 #8
0
        public void SelectSort_EmptyList_Sorted()
        {
            var result = SelectSort.Sort(new List <int> ());

            Assert.Empty(result);
        }
コード例 #9
0
 public void Test()
 {
     int[] list     = { 5, 3, 6, 2, 10 };
     int[] expected = { 2, 3, 5, 6, 10 };
     Assert.Equal(expected, SelectSort.Sort(list));
 }