Example #1
0
        public void Test_FromEnumerable()
        {
            var n = 10;

            var xs   = UnorderedSeq(n).ToArray();
            var heap = BinaryHeap.FromEnumerable(xs);

            var ys = new List <int>();

            while (heap.Count > 0)
            {
                ys.Add(heap.Dequeue());
            }

            Array.Sort(xs);
            ys.IsSeq(xs);
        }
Example #2
0
        public void Test_GetEnumerator()
        {
            var n = 100;

            var heap = BinaryHeap.Create <int>();
            var xs   = UnorderedSeq(n).ToArray();

            foreach (var x in xs)
            {
                heap.Enqueue(x);
            }

            var actual = heap.OrderBy(x => x);

            Array.Sort(xs);
            actual.IsSeq(xs);
        }