Ejemplo n.º 1
0
        public void SortDescending()
        {
            var values = RandomHelper.CreateData(100000).ToArray();
            var actual = TimeHelper.Measure(() => PQ1 <int> .Create(values, true));
            var a      = new int[values.Length];

            TimeHelper.Measure(() => { for (var i = 0; i < a.Length; i++, actual.Pop())
                                       {
                                           a[i] = actual.First;
                                       }
                               });
            var e = TimeHelper.Measure(() => values.OrderByDescending(x => x).ToArray());

            CollectionAssert.AreEqual(e, a);
        }
Ejemplo n.º 2
0
        public void SortDescending_String()
        {
            var values = RandomHelper.CreateData(100000).ToArray();
            var actual = TimeHelper.Measure(() => PQ1 <int> .Create(x => x.ToString(), values, true));
            var a      = new List <int>();

            TimeHelper.Measure(() => { while (actual.Any)
                                       {
                                           a.Add(actual.Pop());
                                       }
                               });
            var e = TimeHelper.Measure(() => values.OrderByDescending(x => x.ToString()).ToArray());

            CollectionAssert.AreEqual(e, a);
        }
Ejemplo n.º 3
0
        public void Sort()
        {
            var values = RandomHelper.CreateData(100000).ToArray();
            var actual = TimeHelper.Measure(() => PQ1 <int> .Create(values));
            var a      = new int[values.Length];

            TimeHelper.Measure(() => { for (var i = 0; i < a.Length; i++)
                                       {
                                           a[i] = actual.Pop();
                                       }
                               });
            var e = (int[])values.Clone();

            TimeHelper.Measure(() => Array.Sort(e));
            CollectionAssert.AreEqual(e, a);
        }
Ejemplo n.º 4
0
        public void SortTake()
        {
            var values = RandomHelper.CreateData(100000).ToArray();
            var actual = TimeHelper.Measure(() =>
            {
                var pq = PQ1 <int> .Create(values);
                var a  = new int[100];
                for (var i = 0; i < a.Length; i++)
                {
                    a[i] = pq.Pop();
                }
                return(a);
            });
            var expected = TimeHelper.Measure(() => values.OrderBy(x => x).Take(100).ToArray());

            CollectionAssert.AreEqual(expected, actual);
        }