min-heap-typed 1.45.0 → 1.45.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/data-structures/hash/hash-map.d.ts +58 -58
- package/dist/data-structures/hash/hash-map.js +73 -73
- package/dist/data-structures/heap/heap.js +21 -12
- package/package.json +2 -2
- package/src/data-structures/binary-tree/avl-tree.ts +7 -7
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +3 -3
- package/src/data-structures/binary-tree/binary-tree.ts +39 -31
- package/src/data-structures/binary-tree/bst.ts +12 -8
- package/src/data-structures/binary-tree/rb-tree.ts +17 -6
- package/src/data-structures/binary-tree/segment-tree.ts +1 -1
- package/src/data-structures/binary-tree/tree-multimap.ts +12 -9
- package/src/data-structures/graph/abstract-graph.ts +46 -31
- package/src/data-structures/graph/directed-graph.ts +10 -5
- package/src/data-structures/graph/map-graph.ts +8 -8
- package/src/data-structures/graph/undirected-graph.ts +9 -9
- package/src/data-structures/hash/hash-map.ts +103 -103
- package/src/data-structures/hash/hash-table.ts +1 -1
- package/src/data-structures/hash/tree-map.ts +2 -1
- package/src/data-structures/hash/tree-set.ts +2 -1
- package/src/data-structures/heap/heap.ts +30 -17
- package/src/data-structures/heap/max-heap.ts +3 -3
- package/src/data-structures/heap/min-heap.ts +3 -3
- package/src/data-structures/linked-list/doubly-linked-list.ts +1 -1
- package/src/data-structures/linked-list/singly-linked-list.ts +1 -1
- package/src/data-structures/matrix/matrix.ts +2 -2
- package/src/data-structures/matrix/matrix2d.ts +1 -1
- package/src/data-structures/matrix/navigator.ts +3 -3
- package/src/data-structures/matrix/vector2d.ts +2 -1
- package/src/data-structures/priority-queue/max-priority-queue.ts +3 -3
- package/src/data-structures/priority-queue/min-priority-queue.ts +3 -3
- package/src/data-structures/priority-queue/priority-queue.ts +3 -3
- package/src/data-structures/queue/deque.ts +5 -4
- package/src/data-structures/queue/queue.ts +2 -2
- package/src/data-structures/tree/tree.ts +1 -1
- package/src/data-structures/trie/trie.ts +1 -1
- package/src/interfaces/binary-tree.ts +2 -2
- package/src/interfaces/graph.ts +1 -1
- package/src/types/data-structures/binary-tree/avl-tree.ts +2 -2
- package/src/types/data-structures/binary-tree/binary-tree.ts +1 -1
- package/src/types/data-structures/binary-tree/bst.ts +2 -2
- package/src/types/data-structures/binary-tree/rb-tree.ts +2 -2
- package/src/types/data-structures/binary-tree/tree-multimap.ts +2 -2
- package/src/types/data-structures/hash/hash-map.ts +6 -6
- package/src/types/data-structures/matrix/navigator.ts +1 -1
- package/src/types/utils/utils.ts +1 -1
- package/src/types/utils/validate-type.ts +18 -4
- package/src/utils/utils.ts +6 -6
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {BinaryTreeNode} from '../data-structures';
|
|
2
|
-
import {BinaryTreeNodeNested, BiTreeDeleteResult, BTNCallback, BTNKey} from '../types';
|
|
1
|
+
import { BinaryTreeNode } from '../data-structures';
|
|
2
|
+
import { BinaryTreeNodeNested, BiTreeDeleteResult, BTNCallback, BTNKey } from '../types';
|
|
3
3
|
|
|
4
4
|
export interface IBinaryTree<V = any, N extends BinaryTreeNode<V, N> = BinaryTreeNodeNested<V>> {
|
|
5
5
|
createNode(key: BTNKey, value?: N['value']): N;
|
package/src/interfaces/graph.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {AVLTreeNode} from '../../../data-structures';
|
|
2
|
-
import {BSTOptions} from './bst';
|
|
1
|
+
import { AVLTreeNode } from '../../../data-structures';
|
|
2
|
+
import { BSTOptions } from './bst';
|
|
3
3
|
|
|
4
4
|
export type AVLTreeNodeNested<T> = AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
|
5
5
|
export type AVLTreeOptions = BSTOptions & {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {BSTNode} from '../../../data-structures';
|
|
2
|
-
import type {BinaryTreeOptions, BTNKey} from './binary-tree';
|
|
1
|
+
import { BSTNode } from '../../../data-structures';
|
|
2
|
+
import type { BinaryTreeOptions, BTNKey } from './binary-tree';
|
|
3
3
|
|
|
4
4
|
export type BSTComparator = (a: BTNKey, b: BTNKey) => number;
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {TreeMultimapNode} from '../../../data-structures';
|
|
2
|
-
import {AVLTreeOptions} from './avl-tree';
|
|
1
|
+
import { TreeMultimapNode } from '../../../data-structures';
|
|
2
|
+
import { AVLTreeOptions } from './avl-tree';
|
|
3
3
|
|
|
4
4
|
export type TreeMultimapNodeNested<T> = TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
|
5
5
|
|
|
@@ -7,11 +7,11 @@ export type HashMapOptions<T> = {
|
|
|
7
7
|
sizeFunction?: number | (() => number);
|
|
8
8
|
fixedLength?: number;
|
|
9
9
|
forEach: (callback: (el: T) => void) => void;
|
|
10
|
-
}
|
|
10
|
+
};
|
|
11
11
|
|
|
12
12
|
export type HashMapLinkedNode<K, V> = {
|
|
13
|
-
key: K
|
|
14
|
-
value: V
|
|
15
|
-
next: HashMapLinkedNode<K, V
|
|
16
|
-
prev: HashMapLinkedNode<K, V
|
|
17
|
-
}
|
|
13
|
+
key: K;
|
|
14
|
+
value: V;
|
|
15
|
+
next: HashMapLinkedNode<K, V>;
|
|
16
|
+
prev: HashMapLinkedNode<K, V>;
|
|
17
|
+
};
|
package/src/types/utils/utils.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export type ToThunkFn = () => ReturnType<TrlFn>;
|
|
2
|
-
export type Thunk = () => ReturnType<ToThunkFn> & {__THUNK__: symbol};
|
|
2
|
+
export type Thunk = () => ReturnType<ToThunkFn> & { __THUNK__: symbol };
|
|
3
3
|
export type TrlFn = (...args: any[]) => any;
|
|
4
4
|
export type TrlAsyncFn = (...args: any[]) => any;
|
|
5
5
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export type KeyValueObject = {[key: string]: any};
|
|
1
|
+
export type KeyValueObject = { [key: string]: any };
|
|
2
2
|
|
|
3
|
-
export type KeyValueObjectWithKey = {[key: string]: any; key: string | number | symbol};
|
|
3
|
+
export type KeyValueObjectWithKey = { [key: string]: any; key: string | number | symbol };
|
|
4
4
|
|
|
5
5
|
export type NonNumberNonObjectButDefined = string | boolean | symbol | null;
|
|
6
6
|
|
|
@@ -16,6 +16,20 @@ export type ObjectWithNumberKey = {
|
|
|
16
16
|
key: number;
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
-
export type RestrictValByKey =
|
|
19
|
+
export type RestrictValByKey =
|
|
20
|
+
| NonNumberNonObjectButDefined
|
|
21
|
+
| ObjectWithoutKey
|
|
22
|
+
| ObjectWithNonNumberKey
|
|
23
|
+
| ObjectWithNumberKey;
|
|
20
24
|
|
|
21
|
-
export type DummyAny =
|
|
25
|
+
export type DummyAny =
|
|
26
|
+
| string
|
|
27
|
+
| number
|
|
28
|
+
| boolean
|
|
29
|
+
| null
|
|
30
|
+
| undefined
|
|
31
|
+
| object
|
|
32
|
+
| symbol
|
|
33
|
+
| void
|
|
34
|
+
| ((...args: []) => any)
|
|
35
|
+
| never;
|
package/src/utils/utils.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
|
|
6
6
|
* @license MIT License
|
|
7
7
|
*/
|
|
8
|
-
import type {Thunk, ToThunkFn, TrlAsyncFn, TrlFn} from '../types';
|
|
8
|
+
import type { Thunk, ToThunkFn, TrlAsyncFn, TrlFn } from '../types';
|
|
9
9
|
|
|
10
10
|
export const uuidV4 = function () {
|
|
11
11
|
return 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'.replace(/[x]/g, function (c) {
|
|
@@ -57,7 +57,7 @@ export const trampoline = (fn: TrlFn) => {
|
|
|
57
57
|
|
|
58
58
|
return result;
|
|
59
59
|
},
|
|
60
|
-
{cont}
|
|
60
|
+
{ cont }
|
|
61
61
|
);
|
|
62
62
|
};
|
|
63
63
|
|
|
@@ -74,7 +74,7 @@ export const trampolineAsync = (fn: TrlAsyncFn) => {
|
|
|
74
74
|
|
|
75
75
|
return result;
|
|
76
76
|
},
|
|
77
|
-
{cont}
|
|
77
|
+
{ cont }
|
|
78
78
|
);
|
|
79
79
|
};
|
|
80
80
|
|
|
@@ -87,13 +87,13 @@ export const getMSB = (value: number): number => {
|
|
|
87
87
|
|
|
88
88
|
export const rangeCheck = (index: number, min: number, max: number, message = 'Index out of bounds.'): void => {
|
|
89
89
|
if (index < min || index > max) throw new RangeError(message);
|
|
90
|
-
}
|
|
90
|
+
};
|
|
91
91
|
|
|
92
92
|
export const throwRangeError = (message = 'The value is off-limits.'): void => {
|
|
93
93
|
throw new RangeError(message);
|
|
94
|
-
}
|
|
94
|
+
};
|
|
95
95
|
|
|
96
96
|
export const isObjOrFunc = (input: unknown): input is Record<string, unknown> | ((...args: any[]) => any) => {
|
|
97
97
|
const inputType = typeof input;
|
|
98
98
|
return (inputType === 'object' && input !== null) || inputType === 'function';
|
|
99
|
-
}
|
|
99
|
+
};
|