Exemplo n.º 1
0
        public void InsertSerial()
        {
            var heap = new BinaryHeap <int>();

            for (int i = 0; i < ItemCount; i++)
            {
                heap.Add(i);
            }

            int root = int.MaxValue;

            for (int i = 0; i < ItemCount; i++)
            {
                var item = heap.PopRoot();
                root.Should().Be.GreaterThanOrEqualTo(item);
                root = item;
            }
        }
Exemplo n.º 2
0
        public void InsertRandom()
        {
            var heap = new BinaryHeap <int>();

            const int maxValue = ItemCount * 100;

            for (int i = 0; i < ItemCount; i++)
            {
                heap.Add(Rnd.Next(1, maxValue));
            }

            int root = int.MaxValue;

            for (int i = 0; i < ItemCount; i++)
            {
                var item = heap.PopRoot();
                root.Should().Be.GreaterThanOrEqualTo(item);
                root = item;
            }
        }
Exemplo n.º 3
0
 public BinaryHeapPriorityQueue(IEnumerable <T> collection, IComparer <T> comparer)
 {
     _heap = new BinaryHeap <T>(collection, comparer);
 }