示例#1
0
        public T RemoveMin()
        {
            if (IsEmpty)
            {
                throw new Exception("heap is empty.");
            }
            var min = Root.Element;

            Root = HeapNode <T> .Marge(Root.LeftChild, Root.RightChild);

            return(min);
        }
示例#2
0
        public void Insert(T element)
        {
            var node = new HeapNode <T>(element);

            Root = HeapNode <T> .Marge(Root, node);
        }
示例#3
0
 public void MargeWith(LeftHeap <T> other)
 {
     Root = HeapNode <T> .Marge(Root, other.Root);
 }