Exemplo n.º 1
0
        public void Dequeue_SmokeTest()
        {
            _minHeap.Enqueue(3);
            _minHeap.Enqueue(4);
            _minHeap.Enqueue(5);
            _minHeap.Enqueue(1);
            _minHeap.Enqueue(2);
            Assert.Equal(5, _minHeap.NumElements);

            Assert.Equal(1, _minHeap.Dequeue());
            Assert.Equal(4, _minHeap.NumElements);

            Assert.Equal(2, _minHeap.Dequeue());
            Assert.Equal(3, _minHeap.NumElements);

            Assert.Equal(3, _minHeap.Dequeue());
            Assert.Equal(2, _minHeap.NumElements);

            Assert.Equal(4, _minHeap.Dequeue());
            Assert.Equal(1, _minHeap.NumElements);

            Assert.Equal(5, _minHeap.Dequeue());
            Assert.Equal(0, _minHeap.NumElements);

            Assert.Equal(default(int), _minHeap.Dequeue());
            Assert.Equal(0, _minHeap.NumElements);
        }
Exemplo n.º 2
0
        public void Dequeue_SmokeTest()
        {
            _heap.Enqueue(1);
            _heap.Enqueue(2);
            _heap.Enqueue(3);
            _heap.Enqueue(4);
            _heap.Enqueue(5);
            Assert.Equal(5, _heap.NumElements);

            Assert.Equal(5, _heap.Dequeue());
            Assert.Equal(4, _heap.Peek());
            Assert.Equal(4, _heap.NumElements);

            Assert.Equal(4, _heap.Dequeue());
            Assert.Equal(3, _heap.Peek());
            Assert.Equal(3, _heap.NumElements);

            Assert.Equal(3, _heap.Dequeue());
            Assert.Equal(2, _heap.Peek());
            Assert.Equal(2, _heap.NumElements);

            Assert.Equal(2, _heap.Dequeue());
            Assert.Equal(1, _heap.Peek());
            Assert.Equal(1, _heap.NumElements);

            Assert.Equal(1, _heap.Dequeue());
            Assert.Equal(0, _heap.Peek());
            Assert.Equal(0, _heap.NumElements);
        }