public object Pop()
{
// if heap is empty, return null
if (_h == null)
{
return null;
}
// top of the heap
HeapNode topOfHeap = _h;
// if the heap doesn't have one item only, go backwards
if (_h.Previous != null)
{
_h = _h.Previous;
_h.Next = _extraItem;
_extraItem.Previous = _h;
}
else
{
_h = null;
}
return topOfHeap;
}