Exemple #1
0
        public void RunAlgorithm(MethodsSort methodsSort, ref int iterator, Algorithms alg)
        {
            SomeSorts sort;
            //DateTime first, second;
            MethodsSequience ms = new MethodsSequience((int)startRange.Value, (int)endRange.Value,
                                                       (int)startPosition.Value, methodsSort);

            Tuple <int, double, decimal[]>[] tempAlg = new Tuple <int, double, decimal[]> [3];
            int[] rangeIteration = { 20, 1000, 5000 };
            for (int i = 0; i < rangeIteration.Length; i++)
            {
                sort = new SomeSorts(rangeIteration[i], ms);

                switch (alg)
                {
                case Algorithms.Bubble:
                    tempAlg[i] = sort.SortBubble(); break;

                case Algorithms.Choice:
                    tempAlg[i] = sort.SortChoice(); break;

                case Algorithms.Quick:
                    tempAlg[i] = sort.QuickSort(); break;

                case Algorithms.Merge:
                    tempAlg[i] = sort.MergeSort(); break;
                }
                int crutch = iterator;

                dataGridView1.Invoke(new Action(() =>
                {
                    dataGridView1[2, crutch].Value = $"{rangeIteration[i]}: {tempAlg[i].Item2:0.###} ms";
                    dataGridView1[3, crutch].Value = tempAlg[i].Item3[0];
                    dataGridView1[4, crutch].Value = tempAlg[i].Item3[1];
                }));
                ++iterator;
            }
            dAlgorithms.Add(tempAlg);
        }
Exemple #2
0
 public MethodsSequience(int startRange, int endRange, int startPosition, MethodsSort methodsSort)
 {
     this.startRange  = startRange;
     this.endRange    = endRange;
     this.methodsSort = methodsSort;
 }