Example #1
0
 // Internal Add
 private void Add(HeapNode <T> current)
 {
     if (current == _head || current.CompareTo(current.parent) >= 0)
     {
         return;
     }
     Swap(current.parent, current);
     Add(current.parent);
 }
Example #2
0
        // Internal Pop
        private static void Pop(HeapNode <T> current)
        {
            if (current.left == null || current.right == null)
            {
                return;
            }
            if (current.CompareTo(current.left) <= 0 && current.CompareTo(current.right) <= 0)
            {
                return;
            }

            if (current.left.CompareTo(current.right) < 0)
            {
                Swap(current, current.left);
                Pop(current.left);
            }
            else
            {
                Swap(current, current.right);
                Pop(current.right);
            }
        }