data-structure-typed 0.8.18 → 1.3.0
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/LICENSE +21 -0
- package/README.md +690 -2
- package/dist/bundle.js +2 -0
- package/dist/bundle.js.LICENSE.txt +13 -0
- package/dist/data-structures/binary-tree/abstract-binary-tree.d.ts +364 -0
- package/dist/data-structures/binary-tree/abstract-binary-tree.js +1308 -0
- package/dist/data-structures/binary-tree/avl-tree.d.ts +85 -18
- package/dist/data-structures/binary-tree/avl-tree.js +110 -37
- package/dist/data-structures/binary-tree/binary-indexed-tree.d.ts +40 -2
- package/dist/data-structures/binary-tree/binary-indexed-tree.js +44 -2
- package/dist/data-structures/binary-tree/binary-tree.d.ts +29 -138
- package/dist/data-structures/binary-tree/binary-tree.js +27 -979
- package/dist/data-structures/binary-tree/bst.d.ts +118 -28
- package/dist/data-structures/binary-tree/bst.js +162 -124
- package/dist/data-structures/binary-tree/index.d.ts +1 -0
- package/dist/data-structures/binary-tree/index.js +1 -0
- package/dist/data-structures/binary-tree/rb-tree.d.ts +18 -1
- package/dist/data-structures/binary-tree/rb-tree.js +40 -2
- package/dist/data-structures/binary-tree/segment-tree.d.ts +63 -13
- package/dist/data-structures/binary-tree/segment-tree.js +80 -17
- package/dist/data-structures/binary-tree/tree-multiset.d.ts +213 -10
- package/dist/data-structures/binary-tree/tree-multiset.js +682 -9
- package/dist/data-structures/graph/abstract-graph.d.ts +270 -64
- package/dist/data-structures/graph/abstract-graph.js +365 -92
- package/dist/data-structures/graph/directed-graph.d.ts +175 -26
- package/dist/data-structures/graph/directed-graph.js +249 -95
- package/dist/data-structures/graph/index.d.ts +1 -0
- package/dist/data-structures/graph/index.js +1 -0
- package/dist/data-structures/graph/map-graph.d.ts +79 -0
- package/dist/data-structures/graph/map-graph.js +111 -0
- package/dist/data-structures/graph/undirected-graph.d.ts +111 -8
- package/dist/data-structures/graph/undirected-graph.js +154 -44
- package/dist/data-structures/hash/coordinate-map.d.ts +39 -2
- package/dist/data-structures/hash/coordinate-map.js +44 -3
- package/dist/data-structures/hash/coordinate-set.d.ts +32 -2
- package/dist/data-structures/hash/coordinate-set.js +34 -0
- package/dist/data-structures/hash/hash-table.d.ts +2 -1
- package/dist/data-structures/hash/hash-table.js +4 -0
- package/dist/data-structures/hash/index.d.ts +5 -0
- package/dist/data-structures/hash/index.js +5 -0
- package/dist/data-structures/hash/pair.d.ts +2 -1
- package/dist/data-structures/hash/pair.js +4 -0
- package/dist/data-structures/hash/tree-map.d.ts +2 -1
- package/dist/data-structures/hash/tree-map.js +4 -0
- package/dist/data-structures/hash/tree-set.d.ts +2 -1
- package/dist/data-structures/hash/tree-set.js +4 -0
- package/dist/data-structures/heap/heap.d.ts +62 -51
- package/dist/data-structures/heap/heap.js +106 -63
- package/dist/data-structures/heap/max-heap.d.ts +13 -4
- package/dist/data-structures/heap/max-heap.js +10 -2
- package/dist/data-structures/heap/min-heap.d.ts +14 -4
- package/dist/data-structures/heap/min-heap.js +11 -2
- package/dist/data-structures/index.d.ts +1 -0
- package/dist/data-structures/index.js +1 -0
- package/dist/data-structures/linked-list/doubly-linked-list.d.ts +193 -57
- package/dist/data-structures/linked-list/doubly-linked-list.js +461 -194
- package/dist/data-structures/linked-list/index.d.ts +1 -0
- package/dist/data-structures/linked-list/index.js +1 -0
- package/dist/data-structures/linked-list/singly-linked-list.d.ts +117 -319
- package/dist/data-structures/linked-list/singly-linked-list.js +338 -557
- package/dist/data-structures/linked-list/skip-linked-list.d.ts +2 -1
- package/dist/data-structures/linked-list/skip-linked-list.js +4 -0
- package/dist/data-structures/matrix/matrix.d.ts +12 -0
- package/dist/data-structures/matrix/matrix.js +14 -0
- package/dist/data-structures/matrix/matrix2d.d.ts +87 -4
- package/dist/data-structures/matrix/matrix2d.js +91 -8
- package/dist/data-structures/matrix/navigator.d.ts +37 -16
- package/dist/data-structures/matrix/navigator.js +28 -0
- package/dist/data-structures/matrix/vector2d.d.ts +156 -29
- package/dist/data-structures/matrix/vector2d.js +184 -55
- package/dist/data-structures/priority-queue/max-priority-queue.d.ts +12 -1
- package/dist/data-structures/priority-queue/max-priority-queue.js +28 -4
- package/dist/data-structures/priority-queue/min-priority-queue.d.ts +12 -1
- package/dist/data-structures/priority-queue/min-priority-queue.js +29 -4
- package/dist/data-structures/priority-queue/priority-queue.d.ts +166 -22
- package/dist/data-structures/priority-queue/priority-queue.js +219 -75
- package/dist/data-structures/queue/deque.d.ts +141 -13
- package/dist/data-structures/queue/deque.js +151 -7
- package/dist/data-structures/queue/queue.d.ts +68 -42
- package/dist/data-structures/queue/queue.js +95 -51
- package/dist/data-structures/stack/stack.d.ts +30 -36
- package/dist/data-structures/stack/stack.js +31 -37
- package/dist/data-structures/tree/index.d.ts +1 -0
- package/dist/data-structures/tree/index.js +17 -0
- package/dist/data-structures/tree/tree.d.ts +14 -0
- package/dist/{types/utils.js → data-structures/tree/tree.js} +26 -19
- package/dist/data-structures/trie/trie.d.ts +39 -6
- package/dist/data-structures/trie/trie.js +81 -12
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/interfaces/abstract-binary-tree.d.ts +90 -0
- package/dist/interfaces/abstract-binary-tree.js +2 -0
- package/dist/interfaces/abstract-graph.d.ts +17 -0
- package/dist/interfaces/abstract-graph.js +2 -0
- package/dist/interfaces/avl-tree.d.ts +9 -0
- package/dist/interfaces/avl-tree.js +2 -0
- package/dist/interfaces/binary-tree.d.ts +6 -0
- package/dist/interfaces/binary-tree.js +2 -0
- package/dist/interfaces/bst.d.ts +17 -0
- package/dist/interfaces/bst.js +2 -0
- package/dist/interfaces/directed-graph.d.ts +12 -0
- package/dist/interfaces/directed-graph.js +2 -0
- package/dist/interfaces/doubly-linked-list.js +2 -0
- package/dist/interfaces/heap.js +2 -0
- package/dist/interfaces/index.d.ts +15 -0
- package/dist/interfaces/index.js +31 -0
- package/dist/interfaces/navigator.js +2 -0
- package/dist/interfaces/priority-queue.js +2 -0
- package/dist/interfaces/rb-tree.d.ts +8 -0
- package/dist/interfaces/rb-tree.js +2 -0
- package/dist/interfaces/segment-tree.js +2 -0
- package/dist/interfaces/singly-linked-list.js +2 -0
- package/dist/interfaces/tree-multiset.d.ts +7 -0
- package/dist/interfaces/tree-multiset.js +2 -0
- package/dist/interfaces/undirected-graph.d.ts +5 -0
- package/dist/interfaces/undirected-graph.js +2 -0
- package/dist/types/data-structures/abstract-binary-tree.d.ts +34 -0
- package/dist/types/data-structures/abstract-binary-tree.js +25 -0
- package/dist/types/data-structures/abstract-graph.d.ts +11 -0
- package/dist/types/data-structures/abstract-graph.js +2 -0
- package/dist/types/data-structures/avl-tree.d.ts +4 -0
- package/dist/types/data-structures/avl-tree.js +2 -0
- package/dist/types/data-structures/binary-tree.d.ts +4 -0
- package/dist/types/data-structures/binary-tree.js +2 -0
- package/dist/types/data-structures/bst.d.ts +13 -0
- package/dist/types/data-structures/bst.js +9 -0
- package/dist/types/data-structures/directed-graph.d.ts +6 -0
- package/dist/types/data-structures/directed-graph.js +9 -0
- package/dist/types/data-structures/doubly-linked-list.js +2 -0
- package/dist/types/data-structures/heap.d.ts +3 -0
- package/dist/types/data-structures/heap.js +2 -0
- package/dist/types/data-structures/index.d.ts +13 -7
- package/dist/types/data-structures/index.js +31 -0
- package/dist/types/data-structures/map-graph.d.ts +1 -0
- package/dist/types/data-structures/map-graph.js +2 -0
- package/dist/types/data-structures/navigator.d.ts +14 -0
- package/dist/types/data-structures/navigator.js +2 -0
- package/dist/types/data-structures/priority-queue.d.ts +7 -0
- package/dist/types/data-structures/priority-queue.js +2 -0
- package/dist/types/data-structures/rb-tree.d.ts +8 -0
- package/dist/types/data-structures/rb-tree.js +8 -0
- package/dist/types/data-structures/segment-tree.d.ts +1 -0
- package/dist/types/data-structures/segment-tree.js +2 -0
- package/dist/types/data-structures/singly-linked-list.js +2 -0
- package/dist/types/data-structures/tree-multiset.d.ts +4 -0
- package/dist/types/data-structures/tree-multiset.js +2 -0
- package/dist/types/helpers.d.ts +1 -0
- package/dist/types/helpers.js +2 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.js +2 -0
- package/dist/types/utils/index.d.ts +2 -0
- package/dist/types/utils/index.js +18 -0
- package/dist/types/utils/utils.d.ts +7 -0
- package/dist/types/utils/utils.js +2 -0
- package/dist/types/utils/validate-type.d.ts +19 -0
- package/dist/types/utils/validate-type.js +2 -0
- package/dist/utils/index.js +17 -0
- package/dist/utils/utils.d.ts +19 -0
- package/dist/{data-structures/trampoline.js → utils/utils.js} +26 -12
- package/package.json +106 -55
- package/.idea/data-structure-typed.iml +0 -12
- package/.idea/modules.xml +0 -8
- package/.idea/vcs.xml +0 -6
- package/dist/data-structures/trampoline.d.ts +0 -25
- package/dist/types/data-structures/binary-tree/aa-tree.d.ts +0 -2
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +0 -21
- package/dist/types/data-structures/binary-tree/b-tree.d.ts +0 -2
- package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +0 -8
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +0 -140
- package/dist/types/data-structures/binary-tree/bst.d.ts +0 -32
- package/dist/types/data-structures/binary-tree/index.d.ts +0 -4
- package/dist/types/data-structures/binary-tree/rb-tree.d.ts +0 -2
- package/dist/types/data-structures/binary-tree/segment-tree.d.ts +0 -33
- package/dist/types/data-structures/binary-tree/splay-tree.d.ts +0 -2
- package/dist/types/data-structures/binary-tree/tree-multiset.d.ts +0 -11
- package/dist/types/data-structures/binary-tree/two-three-tree.d.ts +0 -2
- package/dist/types/data-structures/graph/abstract-graph.d.ts +0 -126
- package/dist/types/data-structures/graph/directed-graph.d.ts +0 -51
- package/dist/types/data-structures/graph/index.d.ts +0 -3
- package/dist/types/data-structures/graph/undirected-graph.d.ts +0 -24
- package/dist/types/data-structures/hash/coordinate-map.d.ts +0 -8
- package/dist/types/data-structures/hash/coordinate-set.d.ts +0 -7
- package/dist/types/data-structures/hash/index.d.ts +0 -1
- package/dist/types/data-structures/heap/heap.d.ts +0 -72
- package/dist/types/data-structures/heap/index.d.ts +0 -3
- package/dist/types/data-structures/heap/max-heap.d.ts +0 -14
- package/dist/types/data-structures/heap/min-heap.d.ts +0 -14
- package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +0 -59
- package/dist/types/data-structures/linked-list/index.d.ts +0 -2
- package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +0 -358
- package/dist/types/data-structures/matrix/index.d.ts +0 -3
- package/dist/types/data-structures/matrix/matrix.d.ts +0 -9
- package/dist/types/data-structures/matrix/matrix2d.d.ts +0 -25
- package/dist/types/data-structures/matrix/navigator.d.ts +0 -31
- package/dist/types/data-structures/matrix/vector2d.d.ts +0 -74
- package/dist/types/data-structures/priority-queue/index.d.ts +0 -3
- package/dist/types/data-structures/priority-queue/max-priority-queue.d.ts +0 -4
- package/dist/types/data-structures/priority-queue/min-priority-queue.d.ts +0 -4
- package/dist/types/data-structures/priority-queue/priority-queue.d.ts +0 -36
- package/dist/types/data-structures/queue/deque.d.ts +0 -37
- package/dist/types/data-structures/queue/index.d.ts +0 -1
- package/dist/types/data-structures/queue/queue.d.ts +0 -76
- package/dist/types/data-structures/stack/index.d.ts +0 -1
- package/dist/types/data-structures/stack/stack.d.ts +0 -69
- package/dist/types/data-structures/trampoline.d.ts +0 -25
- package/dist/types/data-structures/trie/index.d.ts +0 -1
- package/dist/types/data-structures/trie/trie.d.ts +0 -28
- package/dist/types/types/utils.d.ts +0 -46
- package/dist/types/utils.d.ts +0 -46
- package/dist/utils.d.ts +0 -122
- package/dist/utils.js +0 -569
- package/src/data-structures/binary-tree/aa-tree.ts +0 -3
- package/src/data-structures/binary-tree/avl-tree.ts +0 -232
- package/src/data-structures/binary-tree/b-tree.ts +0 -3
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +0 -33
- package/src/data-structures/binary-tree/binary-tree.ts +0 -1088
- package/src/data-structures/binary-tree/bst.ts +0 -404
- package/src/data-structures/binary-tree/index.ts +0 -11
- package/src/data-structures/binary-tree/rb-tree.ts +0 -3
- package/src/data-structures/binary-tree/segment-tree.ts +0 -164
- package/src/data-structures/binary-tree/splay-tree.ts +0 -3
- package/src/data-structures/binary-tree/tree-multiset.ts +0 -21
- package/src/data-structures/binary-tree/two-three-tree.ts +0 -3
- package/src/data-structures/graph/abstract-graph.ts +0 -789
- package/src/data-structures/graph/directed-graph.ts +0 -322
- package/src/data-structures/graph/index.ts +0 -3
- package/src/data-structures/graph/undirected-graph.ts +0 -154
- package/src/data-structures/hash/coordinate-map.ts +0 -24
- package/src/data-structures/hash/coordinate-set.ts +0 -20
- package/src/data-structures/hash/hash-table.ts +0 -1
- package/src/data-structures/hash/index.ts +0 -1
- package/src/data-structures/heap/heap.ts +0 -136
- package/src/data-structures/heap/index.ts +0 -3
- package/src/data-structures/heap/max-heap.ts +0 -22
- package/src/data-structures/heap/min-heap.ts +0 -24
- package/src/data-structures/index.ts +0 -11
- package/src/data-structures/linked-list/doubly-linked-list.ts +0 -258
- package/src/data-structures/linked-list/index.ts +0 -2
- package/src/data-structures/linked-list/singly-linked-list.ts +0 -750
- package/src/data-structures/linked-list/skip-linked-list.ts +0 -1
- package/src/data-structures/matrix/index.ts +0 -4
- package/src/data-structures/matrix/matrix.ts +0 -13
- package/src/data-structures/matrix/matrix2d.ts +0 -125
- package/src/data-structures/matrix/navigator.ts +0 -99
- package/src/data-structures/matrix/vector2d.ts +0 -189
- package/src/data-structures/priority-queue/index.ts +0 -3
- package/src/data-structures/priority-queue/max-priority-queue.ts +0 -12
- package/src/data-structures/priority-queue/min-priority-queue.ts +0 -12
- package/src/data-structures/priority-queue/priority-queue.ts +0 -208
- package/src/data-structures/queue/deque.ts +0 -139
- package/src/data-structures/queue/index.ts +0 -2
- package/src/data-structures/queue/queue.ts +0 -123
- package/src/data-structures/stack/index.ts +0 -1
- package/src/data-structures/stack/stack.ts +0 -104
- package/src/data-structures/trampoline.ts +0 -91
- package/src/data-structures/trie/index.ts +0 -1
- package/src/data-structures/trie/trie.ts +0 -153
- package/src/index.ts +0 -1
- package/src/types/index.ts +0 -1
- package/src/types/patches/index.d.ts +0 -0
- package/src/types/utils.ts +0 -158
- package/src/utils.ts +0 -605
- package/tsconfig.json +0 -53
- /package/dist/{types/data-structures/hash/hash-table.d.ts → interfaces/doubly-linked-list.d.ts} +0 -0
- /package/dist/{types/data-structures/hash/pair.d.ts → interfaces/heap.d.ts} +0 -0
- /package/dist/{types/data-structures/hash/tree-map.d.ts → interfaces/navigator.d.ts} +0 -0
- /package/dist/{types/data-structures/hash/tree-set.d.ts → interfaces/priority-queue.d.ts} +0 -0
- /package/dist/{types/data-structures/linked-list/skip-linked-list.d.ts → interfaces/segment-tree.d.ts} +0 -0
- /package/{src/data-structures/hash/pair.ts → dist/interfaces/singly-linked-list.d.ts} +0 -0
- /package/{src/data-structures/hash/tree-map.ts → dist/types/data-structures/doubly-linked-list.d.ts} +0 -0
- /package/{src/data-structures/hash/tree-set.ts → dist/types/data-structures/singly-linked-list.d.ts} +0 -0
- /package/dist/{types/types → utils}/index.d.ts +0 -0
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
export * from './hash';
|
|
2
|
-
export * from './linked-list';
|
|
3
|
-
export * from './stack';
|
|
4
|
-
export * from './queue';
|
|
5
|
-
export * from './graph';
|
|
6
1
|
export * from './binary-tree';
|
|
7
|
-
export * from './
|
|
2
|
+
export * from './bst';
|
|
3
|
+
export * from './avl-tree';
|
|
4
|
+
export * from './segment-tree';
|
|
5
|
+
export * from './tree-multiset';
|
|
6
|
+
export * from './abstract-graph';
|
|
7
|
+
export * from './map-graph';
|
|
8
|
+
export * from './abstract-binary-tree';
|
|
9
|
+
export * from './rb-tree';
|
|
10
|
+
export * from './directed-graph';
|
|
8
11
|
export * from './priority-queue';
|
|
9
|
-
export * from './
|
|
12
|
+
export * from './heap';
|
|
13
|
+
export * from './singly-linked-list';
|
|
14
|
+
export * from './doubly-linked-list';
|
|
15
|
+
export * from './navigator';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./binary-tree"), exports);
|
|
18
|
+
__exportStar(require("./bst"), exports);
|
|
19
|
+
__exportStar(require("./avl-tree"), exports);
|
|
20
|
+
__exportStar(require("./segment-tree"), exports);
|
|
21
|
+
__exportStar(require("./tree-multiset"), exports);
|
|
22
|
+
__exportStar(require("./abstract-graph"), exports);
|
|
23
|
+
__exportStar(require("./map-graph"), exports);
|
|
24
|
+
__exportStar(require("./abstract-binary-tree"), exports);
|
|
25
|
+
__exportStar(require("./rb-tree"), exports);
|
|
26
|
+
__exportStar(require("./directed-graph"), exports);
|
|
27
|
+
__exportStar(require("./priority-queue"), exports);
|
|
28
|
+
__exportStar(require("./heap"), exports);
|
|
29
|
+
__exportStar(require("./singly-linked-list"), exports);
|
|
30
|
+
__exportStar(require("./doubly-linked-list"), exports);
|
|
31
|
+
__exportStar(require("./navigator"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type MapGraphCoordinate = [number, number];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type Direction = 'up' | 'right' | 'down' | 'left';
|
|
2
|
+
export type Turning = {
|
|
3
|
+
[key in Direction]: Direction;
|
|
4
|
+
};
|
|
5
|
+
export type NavigatorParams<T> = {
|
|
6
|
+
matrix: T[][];
|
|
7
|
+
turning: Turning;
|
|
8
|
+
onMove: (cur: [number, number]) => void;
|
|
9
|
+
init: {
|
|
10
|
+
cur: [number, number];
|
|
11
|
+
charDir: Direction;
|
|
12
|
+
VISITED: T;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BinaryTreeOptions } from './binary-tree';
|
|
2
|
+
import { RBTreeNode } from '../../data-structures/binary-tree';
|
|
3
|
+
export declare enum RBColor {
|
|
4
|
+
RED = "RED",
|
|
5
|
+
BLACK = "BLACK"
|
|
6
|
+
}
|
|
7
|
+
export type RBTreeNodeNested<T> = RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
|
|
8
|
+
export type RBTreeOptions = BinaryTreeOptions & {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type SegmentTreeNodeVal = number;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { TreeMultisetNode } from '../../data-structures/binary-tree';
|
|
2
|
+
import { AVLTreeOptions } from './avl-tree';
|
|
3
|
+
export type TreeMultisetNodeNested<T> = TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
|
|
4
|
+
export type TreeMultisetOptions = Omit<AVLTreeOptions, 'isMergeDuplicatedNodeById'> & {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/types/index.d.ts
CHANGED
package/dist/types/index.js
CHANGED
|
@@ -14,4 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./data-structures"), exports);
|
|
18
|
+
__exportStar(require("./helpers"), exports);
|
|
17
19
|
__exportStar(require("./utils"), exports);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./utils"), exports);
|
|
18
|
+
__exportStar(require("./validate-type"), exports);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type ToThunkFn = () => ReturnType<TrlFn>;
|
|
2
|
+
export type Thunk = () => ReturnType<ToThunkFn> & {
|
|
3
|
+
__THUNK__: Symbol;
|
|
4
|
+
};
|
|
5
|
+
export type TrlFn = (...args: any[]) => any;
|
|
6
|
+
export type TrlAsyncFn = (...args: any[]) => any;
|
|
7
|
+
export type SpecifyOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type KeyValueObject = {
|
|
2
|
+
[key: string]: any;
|
|
3
|
+
};
|
|
4
|
+
export type KeyValueObjectWithId = {
|
|
5
|
+
[key: string]: any;
|
|
6
|
+
id: string | number | symbol;
|
|
7
|
+
};
|
|
8
|
+
export type NonNumberNonObjectButDefined = string | boolean | symbol | null;
|
|
9
|
+
export type ObjectWithoutId = Omit<KeyValueObject, 'id'>;
|
|
10
|
+
export type ObjectWithNonNumberId = {
|
|
11
|
+
[key: string]: any;
|
|
12
|
+
id: string | boolean | symbol | null | object | undefined;
|
|
13
|
+
};
|
|
14
|
+
export type ObjectWithNumberId = {
|
|
15
|
+
[key: string]: any;
|
|
16
|
+
id: number;
|
|
17
|
+
};
|
|
18
|
+
export type RestrictValById = NonNumberNonObjectButDefined | ObjectWithoutId | ObjectWithNonNumberId | ObjectWithNumberId;
|
|
19
|
+
export type DummyAny = string | number | boolean | null | undefined | object | symbol | void | Function | never;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./utils"), exports);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* data-structure-typed
|
|
3
|
+
*
|
|
4
|
+
* @author Tyler Zeng
|
|
5
|
+
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
|
|
6
|
+
* @license MIT License
|
|
7
|
+
*/
|
|
8
|
+
import type { Thunk, ToThunkFn, TrlAsyncFn, TrlFn } from '../types';
|
|
9
|
+
export declare const uuidV4: () => string;
|
|
10
|
+
export declare const arrayRemove: <T>(array: T[], predicate: (item: T, index: number, array: T[]) => boolean) => T[];
|
|
11
|
+
export declare const THUNK_SYMBOL: unique symbol;
|
|
12
|
+
export declare const isThunk: (fnOrValue: any) => boolean;
|
|
13
|
+
export declare const toThunk: (fn: ToThunkFn) => Thunk;
|
|
14
|
+
export declare const trampoline: (fn: TrlFn) => ((...args: [...Parameters<TrlFn>]) => any) & {
|
|
15
|
+
cont: (...args: [...Parameters<TrlFn>]) => Thunk;
|
|
16
|
+
};
|
|
17
|
+
export declare const trampolineAsync: (fn: TrlAsyncFn) => ((...args: [...Parameters<TrlAsyncFn>]) => Promise<any>) & {
|
|
18
|
+
cont: (...args: [...Parameters<TrlAsyncFn>]) => Thunk;
|
|
19
|
+
};
|
|
@@ -9,10 +9,31 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.trampolineAsync = exports.trampoline = exports.toThunk = exports.isThunk = exports.THUNK_SYMBOL = void 0;
|
|
12
|
+
exports.trampolineAsync = exports.trampoline = exports.toThunk = exports.isThunk = exports.THUNK_SYMBOL = exports.arrayRemove = exports.uuidV4 = void 0;
|
|
13
|
+
const uuidV4 = function () {
|
|
14
|
+
return 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'.replace(/[x]/g, function (c) {
|
|
15
|
+
const r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
|
|
16
|
+
return v.toString(16);
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
exports.uuidV4 = uuidV4;
|
|
20
|
+
const arrayRemove = function (array, predicate) {
|
|
21
|
+
let i = -1, len = array ? array.length : 0;
|
|
22
|
+
const result = [];
|
|
23
|
+
while (++i < len) {
|
|
24
|
+
const value = array[i];
|
|
25
|
+
if (predicate(value, i, array)) {
|
|
26
|
+
result.push(value);
|
|
27
|
+
Array.prototype.splice.call(array, i--, 1);
|
|
28
|
+
len--;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return result;
|
|
32
|
+
};
|
|
33
|
+
exports.arrayRemove = arrayRemove;
|
|
13
34
|
exports.THUNK_SYMBOL = Symbol('thunk');
|
|
14
|
-
const isThunk = (
|
|
15
|
-
return typeof
|
|
35
|
+
const isThunk = (fnOrValue) => {
|
|
36
|
+
return typeof fnOrValue === 'function' && fnOrValue.__THUNK__ === exports.THUNK_SYMBOL;
|
|
16
37
|
};
|
|
17
38
|
exports.isThunk = isThunk;
|
|
18
39
|
const toThunk = (fn) => {
|
|
@@ -25,7 +46,7 @@ const trampoline = (fn) => {
|
|
|
25
46
|
const cont = (...args) => (0, exports.toThunk)(() => fn(...args));
|
|
26
47
|
return Object.assign((...args) => {
|
|
27
48
|
let result = fn(...args);
|
|
28
|
-
while ((0, exports.isThunk)(result)) {
|
|
49
|
+
while ((0, exports.isThunk)(result) && typeof result === 'function') {
|
|
29
50
|
result = result();
|
|
30
51
|
}
|
|
31
52
|
return result;
|
|
@@ -36,17 +57,10 @@ const trampolineAsync = (fn) => {
|
|
|
36
57
|
const cont = (...args) => (0, exports.toThunk)(() => fn(...args));
|
|
37
58
|
return Object.assign((...args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
38
59
|
let result = yield fn(...args);
|
|
39
|
-
while ((0, exports.isThunk)(result)) {
|
|
60
|
+
while ((0, exports.isThunk)(result) && typeof result === 'function') {
|
|
40
61
|
result = yield result();
|
|
41
62
|
}
|
|
42
63
|
return result;
|
|
43
64
|
}), { cont });
|
|
44
65
|
};
|
|
45
66
|
exports.trampolineAsync = trampolineAsync;
|
|
46
|
-
const factorial = (0, exports.trampoline)((n, acc = 1) => {
|
|
47
|
-
return n
|
|
48
|
-
// Note: calling factorial.cont instead of factorial directly
|
|
49
|
-
? factorial.cont(n - 1, acc * n)
|
|
50
|
-
: acc;
|
|
51
|
-
});
|
|
52
|
-
// factorial(32768)
|
package/package.json
CHANGED
|
@@ -1,76 +1,127 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "data-structure-typed",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.3.0",
|
|
4
|
+
"description": "Data Structures of Javascript & TypeScript. AVLTree, Binary Search Tree, Binary Tree, Tree Multiset, Graph, Heap, Priority Queue, Linked List.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
6
8
|
"scripts": {
|
|
7
|
-
"
|
|
9
|
+
"build": "rm -rf dist && npx tsc && npm run build:browser",
|
|
10
|
+
"build:browser": "webpack",
|
|
11
|
+
"build:docs": "typedoc --out docs ./src",
|
|
12
|
+
"test": "jest",
|
|
13
|
+
"update:test-deps": "npm i avl-tree-typed binary-tree-typed bst-typed deque-typed directed-graph-typed doubly-linked-list-typed graph-typed heap-typed linked-list-typed max-heap-typed max-priority-queue-typed min-heap-typed min-priority-queue-typed priority-queue-typed singly-linked-list-typed stack-typed tree-multiset-typed trie-typed undirected-graph-typed --save-dev",
|
|
14
|
+
"deps:check": "dependency-cruiser src",
|
|
15
|
+
"build:publish": "npm run test && npm run build && npm run build:docs && npm publish"
|
|
8
16
|
},
|
|
9
17
|
"repository": {
|
|
10
18
|
"type": "git",
|
|
11
19
|
"url": "git+https://github.com/zrwusa/data-structure-typed.git"
|
|
12
20
|
},
|
|
13
21
|
"keywords": [
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"Tree",
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"Tree",
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
22
|
+
"Data Structure",
|
|
23
|
+
"data-structure",
|
|
24
|
+
"Data Structures",
|
|
25
|
+
"data-structures",
|
|
26
|
+
"algorithm",
|
|
27
|
+
"Binary Search Tree",
|
|
28
|
+
"binary-search-tree",
|
|
29
|
+
"Binary Tree",
|
|
30
|
+
"binary-tree",
|
|
31
|
+
"BST",
|
|
32
|
+
"AVL Tree",
|
|
33
|
+
"avl-tree",
|
|
34
|
+
"avl",
|
|
35
|
+
"Tree Multiset",
|
|
36
|
+
"tree-multiset",
|
|
37
|
+
"Tree Multiset",
|
|
38
|
+
"dfs",
|
|
39
|
+
"DFS",
|
|
40
|
+
"dfs iterative",
|
|
41
|
+
"DFS Iterative",
|
|
42
|
+
"bfs",
|
|
43
|
+
"BFS",
|
|
44
|
+
"graph",
|
|
36
45
|
"Graph",
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
46
|
+
"Directed Graph",
|
|
47
|
+
"directed-graph",
|
|
48
|
+
"Undirected Graph",
|
|
49
|
+
"undirected-graph",
|
|
50
|
+
"Heap",
|
|
51
|
+
"Priority Queue",
|
|
52
|
+
"priority-queue",
|
|
53
|
+
"Max Priority Queue",
|
|
54
|
+
"max-priority-queue",
|
|
55
|
+
"Min Priority Queue",
|
|
56
|
+
"min-priority-queue",
|
|
57
|
+
"Deque",
|
|
58
|
+
"Linked List",
|
|
59
|
+
"linked-list",
|
|
60
|
+
"Trie",
|
|
61
|
+
"Prefix Tree",
|
|
62
|
+
"prefix-tree",
|
|
63
|
+
"binary",
|
|
64
|
+
"DataStructure",
|
|
65
|
+
"DataStructures",
|
|
66
|
+
"data",
|
|
67
|
+
"structure",
|
|
68
|
+
"sort",
|
|
69
|
+
"Segment Tree",
|
|
70
|
+
"segment-tree",
|
|
71
|
+
"Binary Indexed Tree",
|
|
72
|
+
"binary-indexed-tree",
|
|
73
|
+
"Linked List",
|
|
74
|
+
"linked-list",
|
|
75
|
+
"Singly Linked List",
|
|
76
|
+
"singly-linked-list",
|
|
77
|
+
"Doubly Linked List",
|
|
78
|
+
"doubly-linked-list",
|
|
57
79
|
"Queue",
|
|
58
|
-
"
|
|
80
|
+
"Object Deque",
|
|
81
|
+
"Array Deque",
|
|
59
82
|
"Stack",
|
|
60
|
-
"
|
|
83
|
+
"Hash",
|
|
84
|
+
"morris",
|
|
85
|
+
"Bellman-Ford ",
|
|
86
|
+
"Dijkstra's Algorithm",
|
|
87
|
+
"Floyd-Warshall Algorithm",
|
|
88
|
+
"Tarjan's Algorithm"
|
|
61
89
|
],
|
|
62
|
-
"author": "Tyler Zeng",
|
|
63
|
-
"license": "
|
|
90
|
+
"author": "Tyler Zeng zrwusa@gmail.com",
|
|
91
|
+
"license": "MIT",
|
|
64
92
|
"bugs": {
|
|
65
93
|
"url": "https://github.com/zrwusa/data-structure-typed/issues"
|
|
66
94
|
},
|
|
67
95
|
"homepage": "https://github.com/zrwusa/data-structure-typed#readme",
|
|
68
|
-
"types": "dist/index.d.ts",
|
|
69
96
|
"devDependencies": {
|
|
70
|
-
"@types/
|
|
71
|
-
"
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
"
|
|
97
|
+
"@types/jest": "^29.5.3",
|
|
98
|
+
"@types/node": "^20.4.9",
|
|
99
|
+
"avl-tree-typed": "^1.21.3",
|
|
100
|
+
"binary-tree-typed": "^1.21.3",
|
|
101
|
+
"bst-typed": "^1.21.3",
|
|
102
|
+
"dependency-cruiser": "^13.1.2",
|
|
103
|
+
"deque-typed": "^1.21.3",
|
|
104
|
+
"directed-graph-typed": "^1.21.3",
|
|
105
|
+
"doubly-linked-list-typed": "^1.21.3",
|
|
106
|
+
"graph-typed": "^1.21.3",
|
|
107
|
+
"heap-typed": "^1.21.3",
|
|
108
|
+
"jest": "^29.6.2",
|
|
109
|
+
"linked-list-typed": "^1.21.3",
|
|
110
|
+
"max-heap-typed": "^1.21.3",
|
|
111
|
+
"max-priority-queue-typed": "^1.21.3",
|
|
112
|
+
"min-heap-typed": "^1.21.3",
|
|
113
|
+
"min-priority-queue-typed": "^1.21.3",
|
|
114
|
+
"priority-queue-typed": "^1.21.3",
|
|
115
|
+
"singly-linked-list-typed": "^1.21.3",
|
|
116
|
+
"stack-typed": "^1.21.3",
|
|
117
|
+
"tree-multiset-typed": "^1.21.3",
|
|
118
|
+
"trie-typed": "^1.21.3",
|
|
119
|
+
"ts-jest": "^29.1.1",
|
|
120
|
+
"ts-loader": "^9.4.4",
|
|
121
|
+
"typedoc": "^0.24.8",
|
|
122
|
+
"typescript": "^4.9.5",
|
|
123
|
+
"undirected-graph-typed": "^1.21.3",
|
|
124
|
+
"webpack": "^5.88.2",
|
|
125
|
+
"webpack-cli": "^5.1.4"
|
|
75
126
|
}
|
|
76
127
|
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<module type="WEB_MODULE" version="4">
|
|
3
|
-
<component name="NewModuleRootManager">
|
|
4
|
-
<content url="file://$MODULE_DIR$">
|
|
5
|
-
<excludeFolder url="file://$MODULE_DIR$/temp" />
|
|
6
|
-
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
|
|
7
|
-
<excludeFolder url="file://$MODULE_DIR$/tmp" />
|
|
8
|
-
</content>
|
|
9
|
-
<orderEntry type="inheritedJdk" />
|
|
10
|
-
<orderEntry type="sourceFolder" forTests="false" />
|
|
11
|
-
</component>
|
|
12
|
-
</module>
|
package/.idea/modules.xml
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<project version="4">
|
|
3
|
-
<component name="ProjectModuleManager">
|
|
4
|
-
<modules>
|
|
5
|
-
<module fileurl="file://$PROJECT_DIR$/.idea/data-structure-ts.iml" filepath="$PROJECT_DIR$/.idea/data-structure-ts.iml" />
|
|
6
|
-
</modules>
|
|
7
|
-
</component>
|
|
8
|
-
</project>
|
package/.idea/vcs.xml
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
export type ArgumentTypes<T extends (...args: any[]) => any> = T extends (...args: infer A) => any ? A : never;
|
|
2
|
-
export declare const THUNK_SYMBOL: unique symbol;
|
|
3
|
-
export interface Thunk<T> extends Function {
|
|
4
|
-
__THUNK__: typeof THUNK_SYMBOL;
|
|
5
|
-
(): T;
|
|
6
|
-
}
|
|
7
|
-
export type ThunkOrValue<T> = T | Thunk<T>;
|
|
8
|
-
export type UnwrapThunkDeep<T> = {
|
|
9
|
-
0: T extends Thunk<infer U> ? UnwrapThunkDeep<U> : T;
|
|
10
|
-
}[T extends ThunkOrValue<T> ? 0 : never];
|
|
11
|
-
export declare const isThunk: <T>(value: any) => value is Thunk<T>;
|
|
12
|
-
export declare const toThunk: <R>(fn: () => R) => Thunk<R>;
|
|
13
|
-
export type UnwrapPromise<T> = T extends Promise<infer U> ? Exclude<U, Promise<T>> : T;
|
|
14
|
-
export type Unbox<T> = UnwrapThunkDeep<UnwrapPromise<T>>;
|
|
15
|
-
export type Cont<A extends any[], R> = (...args: A) => Thunk<Unbox<R>>;
|
|
16
|
-
export interface Trampoline<F extends ((...args: any[]) => any)> {
|
|
17
|
-
(...args: ArgumentTypes<F>): Unbox<ReturnType<F>>;
|
|
18
|
-
cont: Cont<ArgumentTypes<F>, ReturnType<F>>;
|
|
19
|
-
}
|
|
20
|
-
export interface TrampolineAsync<F extends ((...args: any[]) => any)> {
|
|
21
|
-
(...args: ArgumentTypes<F>): Promise<Unbox<ReturnType<F>>>;
|
|
22
|
-
cont: Cont<ArgumentTypes<F>, ReturnType<F>>;
|
|
23
|
-
}
|
|
24
|
-
export declare const trampoline: <F extends (...args: any[]) => any>(fn: F) => Trampoline<F>;
|
|
25
|
-
export declare const trampolineAsync: <F extends (...args: any[]) => any>(fn: F) => TrampolineAsync<F>;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { BST, BSTNode } from './bst';
|
|
2
|
-
import { BinaryTreeNodeId } from './binary-tree';
|
|
3
|
-
export interface AVLTreeDeleted<T> {
|
|
4
|
-
deleted: AVLTreeNode<T> | null;
|
|
5
|
-
needBalanced: AVLTreeNode<T> | null;
|
|
6
|
-
}
|
|
7
|
-
export declare class AVLTreeNode<T> extends BSTNode<T> {
|
|
8
|
-
clone(): AVLTreeNode<T>;
|
|
9
|
-
}
|
|
10
|
-
export declare class AVLTree<T> extends BST<T> {
|
|
11
|
-
createNode(id: BinaryTreeNodeId, val: T, count?: number): AVLTreeNode<T>;
|
|
12
|
-
put(id: BinaryTreeNodeId, val: T | null, count?: number): AVLTreeNode<T> | null;
|
|
13
|
-
remove(id: BinaryTreeNodeId, isUpdateAllLeftSum?: boolean): AVLTreeDeleted<T>[];
|
|
14
|
-
balanceFactor(node: AVLTreeNode<T>): number;
|
|
15
|
-
updateHeight(node: AVLTreeNode<T>): void;
|
|
16
|
-
balancePath(node: AVLTreeNode<T>): void;
|
|
17
|
-
balanceLL(A: AVLTreeNode<T>): void;
|
|
18
|
-
balanceLR(A: AVLTreeNode<T>): void;
|
|
19
|
-
balanceRR(A: AVLTreeNode<T>): void;
|
|
20
|
-
balanceRL(A: AVLTreeNode<T>): void;
|
|
21
|
-
}
|