Example #1
0
 /// <summary>
 ///     Returns the object at the beginning of the queue without removing it.
 /// </summary>
 /// <returns>Object at the beginning of the queue.</returns>
 public T Peek()
 {
     if (_heap.IsEmpty())
     {
         throw new InvalidOperationException("PriorityObject Queue is empty");
     }
     return(_heap.GetMin().Value.Object);
 }
Example #2
0
        public void GetMinTest(IHeap <int> heap, bool isMin)
        {
            var tmpLst = new List <int>(TestList);

            Console.WriteLine("isMin:" + isMin);
            var expected = isMin ? tmpLst.Min() : tmpLst.Max();
            var result   = heap.GetMin().Value;

            Console.WriteLine("Expect:" + expected + " Result:" + result);
            Assert.AreEqual(expected, result);
        }