Beispiel #1
0
        public void CocktailSort()
        {
            var algorithm    = new CocktailSort();
            var sortedVector = algorithm.Sort(DataDefinition.UnsortedVector());

            Assert.Equal(DataDefinition.SortedVector, sortedVector);
        }
        public void TestCocktailSort()
        {
            int[] arr      = { 10, 7, 8, 9, 1, 5 };
            var   actual   = sort.Sort(arr);
            var   expected = new int[] { 1, 5, 7, 8, 9, 10 };

            Assert.Equal(expected, actual);
        }
Beispiel #3
0
        public void CocktailSortTest()
        {
            var cocktail = new CocktailSort <int>();

            cocktail.Items.AddRange(items);

            cocktail.Sort();

            for (int i = 0; i < 10_000; i++)
            {
                Assert.AreEqual(sorted[i], cocktail.Items[i]);
            }
        }
Beispiel #4
0
        public void SortTestCocktail()
        {
            CocktailSort <Int32> cocktail = new CocktailSort <Int32>();

            cocktail.Items.AddRange(list);

            cocktail.Sort();

            for (Int32 i = 0; i < sorted.Length; i++)
            {
                Assert.AreEqual(sorted[i], cocktail.Items[i]);
            }
        }
        public void CocktailSortTest()
        {
            //arrange
            var cocktailSort = new CocktailSort <int>(dataList, "Cocktail");

            //act
            cocktailSort.Sort();
            //assert
            for (int i = 0; i < count; i++)
            {
                Assert.AreEqual(sortedItems[i], cocktailSort.Items[i]);
            }
        }
Beispiel #6
0
        public void CocktailSortTest()
        {
            // arrange
            var cocktail = new CocktailSort <int>();

            cocktail.Items.AddRange(Items);
            // act
            cocktail.Sort();
            // assert
            for (int i = 0; i < cocktail.Items.Count; i++)
            {
                Assert.AreEqual(Sorted[i], cocktail.Items[i]);
            }
        }
Beispiel #7
0
        public void CocktailSortTest()
        {
            //Act
            var cocktail = new CocktailSort <int>();

            cocktail.Items.AddRange(items);
            cocktail.Sort();
            items.Sort();

            //Assert
            for (int i = 0; i < items.Count; i++)
            {
                Assert.AreEqual(items[i], cocktail.Items[i]);
            }
        }
Beispiel #8
0
 private void CocktailSortButtonClick(object sender, EventArgs e)
 {
     if (progressBarCount < 2)
     {
         MessageBox.Show("нечего сортировать");
     }
     else
     {
         var cocktail = new CocktailSort <int>();
         cocktail.Items.AddRange(values.Select(x => x.Bar.Value));
         cocktail.SwapEvent += SwapEvent;
         var time = cocktail.Sort();
         ShowInfoAboutSort(cocktail, time);
     }
 }
Beispiel #9
0
 private void CocktailSortButton_Click(object sender, EventArgs e)
 {
     if (Collection.Count < 10001)
     {
         CocktailLabel.Text = "Time: ";
         var cocktail = new CocktailSort <int>(Collection, "CocktailSort");
         cocktail.Sort();
         DisplayInfoFromSort(cocktail);
         CocktailLabel.Text += cocktail.Time.ToString();
     }
     else
     {
         CocktailLabel.Text = "To much for it ...";
     }
 }
Beispiel #10
0
        private void AllSortButton_Click(object sender, EventArgs e)
        {
            SortDatarichTextBox.Text = "Calculating ... Wait a moment ...";
            BubbleLabel.Text         = "Time: ";
            SelectionLabel.Text      = "Time: ";
            CocktailLabel.Text       = "Time: ";
            GnomeLabel.Text          = "Time: ";
            HeapLabel.Text           = "Time: ";
            InsertionLabel.Text      = "Time: ";
            LSDLabel.Text            = "Time: ";
            MSDLabel.Text            = "Time: ";
            MergeLabel.Text          = "Time: ";
            QuickLabel.Text          = "Time: ";
            ShellLabel.Text          = "Time: ";
            TreeLabel.Text           = "Time: ";
            SortDatarichTextBox.Text = "";
            var min = new List <BaseAlgorithm <int> >();

            if (Collection.Count < 10001)
            {
                var bubble = new BubbleSort <int>(Collection, "BubbleSort");
                bubble.Sort();
                BubbleLabel.Text += bubble.Time.ToString();
                min.Add(bubble);
            }
            if (Collection.Count < 10001)
            {
                var selection = new SelectionSort <int>(Collection, "SelectionSort");
                selection.Sort();
                SelectionLabel.Text += selection.Time.ToString();
                min.Add(selection);
            }
            if (Collection.Count < 10001)
            {
                var cocktail = new CocktailSort <int>(Collection, "CocktailSort");
                cocktail.Sort();
                CocktailLabel.Text += cocktail.Time.ToString();
                min.Add(cocktail);
            }
            if (Collection.Count < 10001)
            {
                var Gnome = new GnomeSort <int>(Collection, "GnomeSort");
                Gnome.Sort();
                GnomeLabel.Text += Gnome.Time.ToString();
                min.Add(Gnome);
            }
            if (Collection.Count < 10001)
            {
                var Insertion = new InsertionSort <int>(Collection, "InsertionSort");
                Insertion.Sort();
                InsertionLabel.Text += Insertion.Time.ToString();
                min.Add(Insertion);
            }
            var Tree = new TreeSort <int>(Collection, "TreeSort");

            Tree.Sort();
            TreeLabel.Text += Tree.Time.ToString();
            min.Add(Tree);
            var Heap = new HeapSort <int>(Collection, "HeapSort");

            Heap.Sort();
            HeapLabel.Text += Heap.Time.ToString();
            min.Add(Heap);
            var LSDRadix = new LSDRadixSort <int>(Collection, "LSDRadixSort");

            LSDRadix.Sort();
            LSDLabel.Text += LSDRadix.Time.ToString();
            min.Add(LSDRadix);
            var MSDRadix = new MSDRadixSort <int>(Collection, "MSDRadixSort");

            MSDRadix.Sort();
            MSDLabel.Text += MSDRadix.Time.ToString();
            min.Add(MSDRadix);
            var Merge = new MergeSort <int>(Collection, "MergeSort");

            Merge.Sort();
            MergeLabel.Text += Merge.Time.ToString();
            min.Add(Merge);
            var Quick = new QuickSort <int>(Collection, "QuickSort");

            Quick.Sort();
            QuickLabel.Text += Quick.Time.ToString();
            min.Add(Quick);
            var Shell = new ShellSort <int>(Collection, "ShellSort");

            Shell.Sort();
            ShellLabel.Text += Shell.Time.ToString();
            min.Add(Shell);
            var best = GetMinTime(min);

            SortDatarichTextBox.Text = $"THE BEST:\n" + best.Name + $"\n{best.Time}";
        }