import PairingHeap from '@heap-data-structure/pairing-heap/src/PairingHeap.js'
PairingHeap
Constructor Summary
Public Constructor | ||
public |
|
Method Summary
Public Methods | ||
public |
decreasekey(ref: Node, value: Object) Decrease-key |
|
public |
delete(ref: *) Ref must be internal ref.prev and ref.next get reset to null |
|
public |
head(): * Find-min: simply return the top element of the heap. |
|
public |
headreference(): * |
|
public |
increasekey(ref: Node, value: Object) Increase-key: remove the item at the key to be increased, replace the key with a larger key, then push the result back into the heap. |
|
public |
merge(other: *) Supposes the same comparison function is used in both trees. |
|
public |
pop(): * Delete-min: remove the root and merge its subtrees. |
|
public |
popreference(): * |
|
public |
push(value: *): * Insert: create a new heap for the inserted element and merge into the original heap. |
|
public |
pushreference(ref: *): * /!\ ref.next = ref.prev = null which means all references that are external to the tree must reset .next and .prev and one must not call PairingHeap#pushreference with an internal reference from this tree or another, except the root of another tree. |
|
public |
|
Public Constructors
public constructor() source
Public Methods
public delete(ref: *) source
Ref must be internal ref.prev and ref.next get reset to null
Params:
Name | Type | Attribute | Description |
ref | * |
public increasekey(ref: Node, value: Object) source
Increase-key: remove the item at the key to be increased, replace the key with a larger key, then push the result back into the heap.
public merge(other: *) source
Supposes the same comparison function is used in both trees. We can call pushreference since other.min.next = other.min.prev = null.
Params:
Name | Type | Attribute | Description |
other | * |
public pop(): * source
Delete-min: remove the root and merge its subtrees. Various strategies are employed.
Return:
* |
public push(value: *): * source
Insert: create a new heap for the inserted element and merge into the original heap.
Params:
Name | Type | Attribute | Description |
value | * |
Return:
* |
public pushreference(ref: *): * source
/!\ ref.next = ref.prev = null which means all references that are external to the tree must reset .next and .prev and one must not call PairingHeap#pushreference with an internal reference from this tree or another, except the root of another tree.
Params:
Name | Type | Attribute | Description |
ref | * |
Return:
* |