Example #1
0
        public HeapNode PopMin()
        {
            if (Nodes.Count > 0)
            {
                HeapNode item = Nodes[0];
                Nodes[0] = Nodes[Nodes.Count - 1];
                Nodes.RemoveAt(Nodes.Count - 1);

                HeapifyDown(0);
                return(item);
            }

            throw new InvalidOperationException("No elements in heap!");
        }
Example #2
0
 public void IncreaseSearchCount(HeapNode item, int increaseValue)
 {
     item.SearchCount += increaseValue;
     HeapifyDown(0);
 }
Example #3
0
 public void Add(HeapNode item)
 {
     Nodes.Add(item);
     HeapifyUp(Nodes.Count - 1);
 }