private void testDeleteMin(BasicHeap <DSInteger> the_heap)
        {
            //removing of the default items handled in testAdd()
            while (!the_heap.isEmpty())
            {
                the_heap.deleteMin();
            }
            Assert.AreEqual(null, the_heap.deleteMin());
            Assert.AreEqual(true, the_heap.isEmpty());

            //adding items after all are removed, then check for correct state
            the_heap.add(new DSInteger(5));
            Assert.AreEqual(5, the_heap.deleteMin().value);
            Assert.AreEqual(null, the_heap.deleteMin());
            Assert.AreEqual(true, the_heap.isEmpty()); Assert.AreEqual(true, the_heap.isEmpty());
        }
 private void testPeek(BasicHeap <DSInteger> the_heap)
 {
     if (the_heap.min_heap) //min heap
     {
         Assert.AreEqual(5, the_heap.peek().value);
         Assert.AreEqual(5, the_heap.peek().value);
         the_heap.deleteMin();
         Assert.AreEqual(10, the_heap.peek().value);
         Assert.AreEqual(10, the_heap.peek().value);
     }
     else //max heap
     {
         Assert.AreEqual(110, the_heap.peek().value);
         Assert.AreEqual(110, the_heap.peek().value);
         the_heap.deleteMin();
         Assert.AreEqual(100, the_heap.peek().value);
         Assert.AreEqual(100, the_heap.peek().value);
     }
 }
        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>
 /// Dequeues an element from the queue. This will be the min/max element
 /// according to the ordering.
 /// </summary>
 /// <returns>the min/max element.</returns>
 public T dequeue()
 {
     try
     {
         return(my_heap.deleteMin());
     }
     catch (ClassCastException the_ex) //this will be thrown when percolateDown() is called
     {
         throw new ClassCastException("You did not provide a comparator to the priority queue and your " +
                                      "elements are not comparable.");
     }
 }
 private void testAdd(BasicHeap <DSInteger> the_heap)
 {
     //min heap
     if (the_heap.min_heap)
     {
         Assert.AreEqual(5, the_heap.deleteMin().value);
         Assert.AreEqual(10, the_heap.deleteMin().value);
         Assert.AreEqual(20, the_heap.deleteMin().value);
         Assert.AreEqual(30, the_heap.deleteMin().value);
         Assert.AreEqual(40, the_heap.deleteMin().value);
         Assert.AreEqual(50, the_heap.deleteMin().value);
         Assert.AreEqual(60, the_heap.deleteMin().value);
         Assert.AreEqual(70, the_heap.deleteMin().value);
         Assert.AreEqual(80, the_heap.deleteMin().value);
         Assert.AreEqual(90, the_heap.deleteMin().value);
         Assert.AreEqual(100, the_heap.deleteMin().value);
         Assert.AreEqual(110, the_heap.deleteMin().value);
     }
     else //max heap
     {
         Assert.AreEqual(110, the_heap.deleteMin().value);
         Assert.AreEqual(100, the_heap.deleteMin().value);
         Assert.AreEqual(90, the_heap.deleteMin().value);
         Assert.AreEqual(80, the_heap.deleteMin().value);
         Assert.AreEqual(70, the_heap.deleteMin().value);
         Assert.AreEqual(60, the_heap.deleteMin().value);
         Assert.AreEqual(50, the_heap.deleteMin().value);
         Assert.AreEqual(40, the_heap.deleteMin().value);
         Assert.AreEqual(30, the_heap.deleteMin().value);
         Assert.AreEqual(20, the_heap.deleteMin().value);
         Assert.AreEqual(10, the_heap.deleteMin().value);
         Assert.AreEqual(5, the_heap.deleteMin().value);
     }
 }