Beispiel #1
0
        /**
         * Default settings:
         * range = (-100, 100),
         * startSeq = 0.
         */

        /**
         * Init constructors(Инициализация конструкторов)
         */
        public SomeSorts(int sizeArray, MethodsSequience sMethod)
        {
            this.sizeArray = sizeArray;
            currentMethod  = sMethod.methodsSort;
            rangeNumbers   = Tuple.Create(sMethod.startRange, sMethod.endRange);
            startSequence  = sMethod.startPosition;
            GenerateArray();
        }
Beispiel #2
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);
        }