Ejemplo n.º 1
0
 private void testClear(BasicHeap <DSInteger> the_heap)
 {
     Assert.AreEqual(false, the_heap.isEmpty());
     Assert.AreEqual(true, the_heap.size() > 0);
     the_heap.clear();
     Assert.AreEqual(true, the_heap.isEmpty());
     Assert.AreEqual(0, the_heap.size());
 }
Ejemplo n.º 2
0
        private void testSize(BasicHeap <DSInteger> the_heap)
        {
            //check initial size
            Assert.AreEqual(12, the_heap.size());

            //make sure the size alters when removing
            the_heap.deleteMin();
            Assert.AreEqual(11, the_heap.size());

            //make sure the size reduces itself to zero
            while (!the_heap.isEmpty())
            {
                the_heap.deleteMin();
            }
            Assert.AreEqual(0, the_heap.size());

            //make sure the size does not go below 0
            the_heap.deleteMin();
            Assert.AreEqual(0, the_heap.size());
        }
 /// <summary>
 /// Shows the number of elements in the heap.
 /// </summary>
 /// <returns>the number of elements in the heap.</returns>
 public int size()
 {
     return(my_heap.size());
 }