Ejemplo n.º 1
0
 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);
     }
 }
 /// <summary>
 /// Reveals the min/max element in the heap but does not remove it.
 /// </summary>
 /// <returns>the min/max element.</returns>
 public T poll()
 {
     return(my_heap.peek());
 }