HeapBaseTElementUpdateKeyTKeyType Method |
Updates the key of the element passed in. Only use this method for elements where the key is a property of the element, not the element itself.
This means that if you have a heap with value typed elements (e.g. integers), updating the key is updating the value of the element itself, and because
a heap might contain elements with the same value, this could lead to undefined results.
Namespace:
SD.Tools.Algorithmia.Heaps
Assembly:
SD.Tools.Algorithmia (in SD.Tools.Algorithmia.dll) Version: 1.3.0.0 (1.3.17.0314)
Syntax public abstract void UpdateKey<TKeyType>(
TElement element,
Action<TElement, TKeyType> keyUpdateFunc,
TKeyType newValue
)
Public MustOverride Sub UpdateKey(Of TKeyType) (
element As TElement,
keyUpdateFunc As Action(Of TElement, TKeyType),
newValue As TKeyType
)
Parameters
- element
- Type: TElement
The element which key has to be updated - keyUpdateFunc
- Type: SystemActionTElement, TKeyType
The key update func, which takes 2 parameters: the element to update and the new key value. - newValue
- Type: TKeyType
The new value for the key.
Type Parameters
- TKeyType
- The type of the key type.
Remarks The element to update is first looked up in the heap. If the new key violates the heap property (e.g. the key is bigger than the
key of the parent in a max-heap) the elements in the heap are restructured in such a way that the heap again obeys the heap property.
See Also