-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathfibonacci-heap.d.ts
More file actions
79 lines (67 loc) · 1.88 KB
/
fibonacci-heap.d.ts
File metadata and controls
79 lines (67 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/**
* @license
* Copyright Daniel Imms <http://www.growingwiththeweb.com>
* Released under MIT license. See LICENSE in the project root for details.
*/
declare module '@tyriar/fibonacci-heap' {
export type CompareFunction<K, V> = (a: INode<K, V>, b: INode<K, V>) => number;
export interface INode<K, V> {
key: K;
value?: V;
}
/**
* A Fibonacci heap data structure with a key and optional value.
*/
export class FibonacciHeap<K, V> {
/**
* Creates a new Fibonacci heap.
* @param compare A custom compare function.
*/
constructor(compare?: CompareFunction<K, V>);
/**
* Clears the heap's data, making it an empty heap.
*/
clear(): void;
/**
* Decreases a key of a node.
* @param node The node to decrease the key of.
* @param newKey The new key to assign to the node.
*/
decreaseKey(node: INode<K, V>, newKey: K): void
/**
* Deletes a node.
* @param node The node to delete.
*/
delete(node: INode<K, V>): void;
/**
* Extracts and returns the minimum node from the heap.
* @return The heap's minimum node or null if the heap is empty.
*/
extractMinimum(): INode<K, V> | null;
/**
* Returns the minimum node from the heap.
* @return The heap's minimum node or null if the heap is empty.
*/
findMinimum(): INode<K, V> | null;
/**
* Inserts a new key-value pair into the heap.
* @param key The key to insert.
* @param value The value to insert.
* @return node The inserted node.
*/
insert(key: K, value?: V): INode<K, V>;
/**
* @return Whether the heap is empty.
*/
isEmpty(): boolean;
/**
* @return The size of the heap.
*/
size(): number;
/**
* Joins another heap to this heap.
* @param other The other heap.
*/
union(other: FibonacciHeap<K, V>): void;
}
}