public void DecreaseKey(IPair <TKey, TValue> node, TKey newKey) { if (newKey.CompareTo(node.Key) > 0) { throw new ArgumentException("decreaseKey() got larger key value"); } var nodeH = node as FibonacciHeapNode <TKey, TValue>; nodeH.Key = newKey; var parent = nodeH.Parent; if ((parent != null) && (node.CompareTo(parent) < 0)) { Cut(nodeH, parent); CascadingCut(parent); } if (node.CompareTo(_minNode) < 0) { _minNode = nodeH; } }
private void LinearAddition(IPair <TKey, TValue> item) { for (int i = 0; i < _list.Count; i++) { var otherNode = _list[i]; if (item.CompareTo(otherNode) < 0) { _list.Insert(i, item); return; } } _list.Add(item); }