private void removeMapping(T currentValue, BinomialHeapNode <T> node)
 {
     heapMapping[currentValue].Remove(node);
     if (heapMapping[currentValue].Count == 0)
     {
         heapMapping.Remove(currentValue);
     }
 }
 private void addMapping(T newItem, BinomialHeapNode <T> newNode)
 {
     if (heapMapping.ContainsKey(newItem))
     {
         heapMapping[newItem].Add(newNode);
     }
     else
     {
         heapMapping[newItem] = new List <BinomialHeapNode <T> >(new[] { newNode });
     }
 }
        /// <summary>
        /// Update the Heap with new value for this node pointer
        /// O(log(n)) complexity
        /// </summary>
        public void IncrementKey(BinomialHeapNode <T> node)
        {
            var current = node;

            while (current.Parent != null &&
                   current.Value.CompareTo(current.Parent.Value) > 0)
            {
                var tmp = current.Value;
                current.Value        = current.Parent.Value;
                current.Parent.Value = tmp;

                current = current.Parent;
            }
        }
        /// <summary>
        /// Time complexity: O(log(n)).
        /// </summary>
        public void Insert(T newItem)
        {
            var newNode = new BinomialHeapNode <T>(newItem);

            var newHeapForest = new DoublyLinkedList <BinomialHeapNode <T> >();

            newHeapForest.InsertFirst(newNode);

            //updated pointer
            mergeSortedForests(newHeapForest);

            meld();

            addMapping(newItem, newNode);

            Count++;
        }
        /// <summary>
        /// O(log(n)) complexity
        /// </summary>
        /// <param name="newItem"></param>
        public BinomialHeapNode <T> Insert(T newItem)
        {
            var newNode = new BinomialHeapNode <T>(newItem);

            var newHeapForest = new DoublyLinkedList <BinomialHeapNode <T> >();

            newHeapForest.InsertFirst(newNode);

            //updated pointer
            MergeSortedForests(newHeapForest);

            Meld();

            Count++;

            return(newNode);
        }
 private void updateNodeValue(T currentValue, T newValue, BinomialHeapNode <T> node)
 {
     removeMapping(currentValue, node);
     node.Value = newValue;
     addMapping(newValue, node);
 }