Exemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            decimal sortNum;

            try
            {
                sortNum = decimal.Parse(textBox1.Text);
            }
            catch
            {
                MessageBox.Show("任务号输入错误,请重新输入!");
                return;
            }
            int row = SortClass.SpecialSmokePosition(sortNum);

            if (row > 0)
            {
                MessageBox.Show("任务定位成功");
            }
            else if (row == 0)
            {
                MessageBox.Show("任务定位成功,但受影响的行数为0");
            }
            else
            {
                MessageBox.Show("任务定位失败");
            }
        }
Exemplo n.º 2
0
        public void Test_SortWthInterface_KeyMax()
        {
            double[][] a = new double[3][];
            a[0] = new double[2] {
                2, 2
            };
            a[1] = new double[2] {
                3, 3
            };
            a[2] = new double[3] {
                1, 1, 1
            };
            IComparer <Double[]> comparer = new SumComparer();

            SortClass.SortWithInterfaces(a, comparer);
            CollectionAssert.AreEqual(a[0], new double[3] {
                1, 1, 1
            });
            CollectionAssert.AreEqual(a[1], new double[2] {
                2, 2
            });
            CollectionAssert.AreEqual(a[2], new double[2] {
                3, 3
            });
        }
Exemplo n.º 3
0
        void Bind()
        {
            decimal ctype      = 2;
            decimal machineseq = 0;

            if (RBLishi.Checked)
            {
                ctype = 2;
            }
            else
            {
                ctype = 3;
            }
            if (textBox1.Text == "")
            {
                machineseq = 0;
            }
            else
            {
                bool flag = decimal.TryParse(textBox1.Text, out machineseq);
                if (!flag)
                {
                    MessageBox.Show("输入错误");
                    return;
                }
            }

            List <SortReplaceInfo> list = new List <SortReplaceInfo>();

            list = SortClass.GetSortThroughInfo(ctype, machineseq);
            dataGridView1.DataSource = list;
        }
Exemplo n.º 4
0
        void Bind()
        {
            try
            {
                list = new List <SortInfo>();
                list = SortClass.GetSortInfo();

                if (list.Count > 0)
                {
                    SortInfo lishi = list.Where(item => item.Ctype == 2).GroupBy(item => item.Ctype).Select(item => new SortInfo {
                        Ctype = 0, CigaretteCode = "立式烟仓", CigaretteName = "立式烟仓分拣进度", MachineSeq = 0, SortedNum = item.Sum(x => x.SortedNum), TotalNum = item.Sum(x => x.TotalNum), UnSortNum = item.Sum(x => x.UnSortNum)
                    }).FirstOrDefault();
                    SortInfo woshi = list.Where(item => item.Ctype == 3).GroupBy(item => item.Ctype).Select(item => new SortInfo {
                        Ctype = 0, CigaretteCode = "卧式烟仓", CigaretteName = "卧式烟仓分拣进度", MachineSeq = 0, SortedNum = item.Sum(x => x.SortedNum), TotalNum = item.Sum(x => x.TotalNum), UnSortNum = item.Sum(x => x.UnSortNum)
                    }).FirstOrDefault();
                    SortInfo teyixing = list.Where(item => item.Ctype == 1).GroupBy(item => item.Ctype).Select(item => new SortInfo {
                        Ctype = 0, CigaretteCode = "特异型烟道", CigaretteName = "特异型烟道分拣进度", MachineSeq = 0, SortedNum = item.Sum(x => x.SortedNum), TotalNum = item.Sum(x => x.TotalNum), UnSortNum = item.Sum(x => x.UnSortNum)
                    }).FirstOrDefault();

                    SortInfo zongshu = new SortInfo()
                    {
                        SortedNum     = list.Sum(item => item.SortedNum),
                        UnSortNum     = list.Sum(item => item.UnSortNum),
                        TotalNum      = list.Sum(item => item.TotalNum),
                        Ctype         = 0,
                        MachineSeq    = 0,
                        CigaretteCode = "总分拣量",
                        CigaretteName = "总分拣量"
                    };

                    list.Insert(0, zongshu);

                    if (lishi != null)
                    {
                        list.Insert(1, lishi);
                    }
                    if (woshi != null)
                    {
                        list.Insert(2, woshi);
                    }
                    if (teyixing != null)
                    {
                        list.Insert(3, teyixing);
                    }

                    DgvSort.DataSource = list.OrderBy(item => item.MachineSeq).OrderBy(item => item.Ctype).ToList();
                }
                else
                {
                    DgvSort.DataSource = list;
                    MessageBox.Show("当前没有分拣数据");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Exemplo n.º 5
0
 static void Main(string[] args)
 {
     string[] array = new string[] { "we're calling", "for", "freedom", "aaaaaaaaaaaaaaaaaaaaaaaa", "fantasy_is_about_to_end" };
     SortClass.Sort(array, Compare);
     foreach (var item in array)
     {
         Console.WriteLine(item);
     }
 }
 public void QuickSort_PositiveNumbersTest()
 {
     int[] massive       = { 5, 3, 7, 9, 1 };
     int[] sortedMassive = { 1, 3, 5, 7, 9 };
     SortClass.QuickSort(massive);
     for (int i = 0; i < massive.Length; i++)
     {
         Assert.AreEqual(massive[i], sortedMassive[i]);
     }
 }
 public void QuickSort_NegativeNumbersTest()
 {
     int[] massive       = { -23, -48, -34, -9, -4 };
     int[] sortedMassive = { -48, -34, -23, -9, -4 };
     SortClass.QuickSort(massive);
     for (int i = 0; i < massive.Length; i++)
     {
         Assert.AreEqual(massive[i], sortedMassive[i]);
     }
 }
        public void MergeSort_NegativeNumbersTest()
        {
            int[] massive         = { -23, -48, -34, -9, -4 };
            int[] sortedMassive   = { -48, -34, -23, -9, -4 };
            var   mergeSortResult = SortClass.MergeSort(massive);

            for (int i = 0; i < mergeSortResult.Length; i++)
            {
                Assert.AreEqual(mergeSortResult[i], sortedMassive[i]);
            }
        }
 public void QuickSort_IntMaxAndMinValueAndZeroTest()
 {
     int[] massive       = { 0, int.MaxValue, int.MinValue };
     int[] sortedMassive = { int.MinValue, 0, int.MaxValue };
     SortClass.QuickSort(massive);
     for (int i = 0; i < massive.Length; i++)
     {
         Assert.AreEqual(massive[i], sortedMassive[i]);
         Assert.Equals(massive, sortedMassive);
     }
 }
        public void QuickSort_Test4()
        {
            int[] array    = new int[0];
            int[] expected = new int[0];

            SortClass sortClass = new SortClass();

            array = sortClass.QuickSort(array);

            CollectionAssert.AreEqual(expected, array);
        }
        public void MergeSort_Test2()
        {
            int[] array    = null;
            int[] expected = null;

            SortClass sortClass = new SortClass();

            array = sortClass.MergeSort(array);

            CollectionAssert.AreEqual(expected, array);
        }
        public void MergeSort_Test3()
        {
            int[] array    = new int[] { 5, 4, 3, 2, 1 };
            int[] expected = new int[] { 1, 2, 3, 4, 5 };

            SortClass sortClass = new SortClass();

            array = sortClass.MergeSort(array);

            CollectionAssert.AreEqual(expected, array);
        }
        public void QuickSort_Test1()
        {
            int[] array    = new int[] { 6, 4, 8, 2, 9, 1 };
            int[] expected = new int[] { 1, 2, 4, 6, 8, 9 };

            SortClass sortClass = new SortClass();

            array = sortClass.QuickSort(array);

            CollectionAssert.AreEqual(expected, array);
        }
        public void MergeSort_IntMaxAndMinValueAndZeroTest()
        {
            int[] massive         = { 0, int.MaxValue, int.MinValue };
            int[] sortedMassive   = { int.MinValue, 0, int.MaxValue };
            var   mergeSortResult = SortClass.MergeSort(massive);

            for (int i = 0; i < mergeSortResult.Length; i++)
            {
                Assert.AreEqual(mergeSortResult[i], sortedMassive[i]);
            }
        }
        public void MergeSort_PositiveNumbersTest()
        {
            int[] massive         = { 5, 3, 7, 9, 1 };
            int[] sortedMassive   = { 1, 3, 5, 7, 9 };
            var   mergeSortResult = SortClass.MergeSort(massive);

            for (int i = 0; i < mergeSortResult.Length; i++)
            {
                Assert.AreEqual(mergeSortResult[i], sortedMassive[i]);
            }
        }
Exemplo n.º 16
0
        public void test()
        {
            Stopwatch timePerParse;
            var       numbers       = 16;
            long      ticksThisTime = 0;

            int[] datata = new int[numbers];
            for (int i = 0; i < numbers; i++)
            {
                Random random = new Random();
                var    number = random.Next(0, 10000);
                datata[i] = number;
            }
            var data2 = new int[datata.Length];
            var data3 = new int[datata.Length];
            var data4 = new int[datata.Length];
            var data5 = new int[datata.Length];

            datata.CopyTo(data2, 0);
            datata.CopyTo(data3, 0);
            datata.CopyTo(data4, 0);
            datata.CopyTo(data5, 0);

            timePerParse = Stopwatch.StartNew();
            SortClass.Sort(ref datata);
            timePerParse.Stop();
            ticksThisTime = timePerParse.ElapsedTicks;
            Console.WriteLine("MainSort     " + ticksThisTime);


            timePerParse = Stopwatch.StartNew();
            SortClass.QuickSort(ref data2, data2[0], data2.Length - 1);
            timePerParse.Stop();
            ticksThisTime = timePerParse.ElapsedTicks;
            Console.WriteLine("QuickSort     " + ticksThisTime);


            timePerParse = Stopwatch.StartNew();
            SortClass.InsertionSort(ref data4);
            timePerParse.Stop();
            ticksThisTime = timePerParse.ElapsedTicks;
            Console.WriteLine("InsertionSort     " + ticksThisTime);

            timePerParse = Stopwatch.StartNew();
            SortClass.HeapSort(ref data5);
            timePerParse.Stop();
            ticksThisTime = timePerParse.ElapsedTicks;
            Console.WriteLine("HeapSort      " + ticksThisTime);
        }
Exemplo n.º 17
0
        private void updateAfterEditPrice()
        {
            List <goodPrice>      goodPrice = service.getAllGoodPrice();
            SortClass <goodPrice> sorting   = new SortClass <WcfService.goodPrice>();

            goodPrice.Sort(sorting);
            if (lvGoodsPrices.Items.Count != 0)
            {
                this.lvGoodsPrices.Items.Clear();
            }
            for (int i = 0; i < goodPrice.Count; i++)
            {
                this.lvGoodsPrices.Items.Add(goodPrice[i]);
            }
        }
Exemplo n.º 18
0
 //Method call QuickSort
 private static void Sort(object o)
 {
     if (o is ArrayAndComparer <T> )
     {
         //Cast object and appeal to array
         ArrayAndComparer <T> args = o as ArrayAndComparer <T>;
         SortClass.Sort <T>(args.Array, args.Compare);
         //Notificaton that sorting is complete
         OnSorting?.Invoke(args.Array);
         OnSorting -= OnSortingArrayHandler <T>;
     }
     else
     {
         throw new InvalidCastException("Object is not array and comparer");
     }
 }
Exemplo n.º 19
0
        static void Main(string[] args)
        {
            var numberList = new List <int>
            {
                5,
                7,
                1,
                2,
                3,
                99
            };

            var sort   = new SortClass(new SortAsc(), numberList);
            var result = sort.Sort();

            foreach (var item in result)
            {
                Console.WriteLine(item);
            }

            Console.ReadKey();
        }
Exemplo n.º 20
0
 public void Test_Sort_AcceptedDelegate_KeySum()
 {
     double[][] a = new double[3][];
     a[0] = new double[2] {
         2, 2
     };
     a[1] = new double[2] {
         3, 3
     };
     a[2] = new double[3] {
         1, 1, 1
     };
     SortClass.Sort(a, KeySum);
     CollectionAssert.AreEqual(a[0], new double[3] {
         1, 1, 1
     });
     CollectionAssert.AreEqual(a[1], new double[2] {
         2, 2
     });
     CollectionAssert.AreEqual(a[2], new double[2] {
         3, 3
     });
 }
Exemplo n.º 21
0
 public void Test_SortWithDelegate_KeyMax()
 {
     double[][] a = new double[3][];
     a[0] = new double[2] {
         2, 2
     };
     a[1] = new double[2] {
         3, 3
     };
     a[2] = new double[3] {
         1, 1, 1
     };
     SortClass.SortWithDelegate(a, KeyMax);
     CollectionAssert.AreEqual(a[0], new double[3] {
         1, 1, 1
     });
     CollectionAssert.AreEqual(a[1], new double[2] {
         2, 2
     });
     CollectionAssert.AreEqual(a[2], new double[2] {
         3, 3
     });
 }
Exemplo n.º 22
0
 public void TestSortByMaxInRow(TestData testdata)
 {
     int[][] result = SortClass.JuggedArraySort(testdata.SourceArray, testdata.Option, testdata.OrderOption);
     Assert.That(result, Is.EqualTo(testdata.ExpectedArray));
 }
 public void QuickSort_NullArray()
 {
     SortClass.QuickSort(null);
 }
Exemplo n.º 24
0
    IEnumerator Sort()
    {
        SortClass <int>     sortclass  = new SortClass <int>();
        IntComparer         com        = new IntComparer();
        int                 n          = 0;
        SortParameter <int> sort_param = null;

        switch (sort_type)
        {
        case SortType.Buble:
        {
            sort_param = new BubleSortParameter <int>(
                com,
                () => { },
                (state, sorting_items, item_states) =>
                {
                    ++n;
                    if (dstint_text)
                    {
                        DistSortArray(state, sorting_items, item_states);
                    }
                }
                );
        }
        break;

        case SortType.Quick:
        case SortType.RandomQuick:
        {
            sort_param = new QuickSortParameter <int>(
                com,
                () => { },
                (state, sorting_items, item_states) =>
                {
                    ++n;
                    if (dstint_text)
                    {
                        DistSortArray(state, sorting_items, item_states);
                    }
                }
                );
        }
        break;

        case SortType.Bitonic_NotUseGPGPUDemo:
        {
            sort_param = new BytonicSortParameter <int>(
                com,
                () => { },
                (state, sorting_items, item_states) =>
                {
                    ++n;
                    if (dstint_text)
                    {
                        DistSortArray(state, sorting_items, item_states);
                    }
                }
                );
        }
        break;
        }
        yield return(sortclass.SortUseIEnumerator(
                         items,
                         sort_param,
                         new WaitForSeconds(wait),
                         sort_type
                         ));

        Debug.Log("操作回数:" + n + "回");
    }
Exemplo n.º 25
0
 public SortClass(string a, string b, SortClass c)
     : this(a, b)
 {
     C = c;
 }
 public void MergeSort_NullArray()
 {
     SortClass.MergeSort(null);
 }