data-structure-typed 0.9.16 → 1.3.1
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 +665 -172
- package/dist/bundle.js +2 -0
- package/dist/bundle.js.LICENSE.txt +13 -0
- package/dist/data-structures/binary-tree/aa-tree.js +2 -5
- 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 -14
- package/dist/data-structures/binary-tree/avl-tree.js +142 -116
- package/dist/data-structures/binary-tree/b-tree.js +2 -5
- package/dist/data-structures/binary-tree/binary-indexed-tree.d.ts +39 -1
- package/dist/data-structures/binary-tree/binary-indexed-tree.js +54 -13
- package/dist/data-structures/binary-tree/binary-tree.d.ts +29 -126
- package/dist/data-structures/binary-tree/binary-tree.js +31 -1093
- package/dist/data-structures/binary-tree/bst.d.ts +117 -23
- package/dist/data-structures/binary-tree/bst.js +233 -240
- 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 -5
- package/dist/data-structures/binary-tree/segment-tree.d.ts +61 -11
- package/dist/data-structures/binary-tree/segment-tree.js +126 -93
- package/dist/data-structures/binary-tree/splay-tree.js +2 -5
- package/dist/data-structures/binary-tree/tree-multiset.d.ts +213 -6
- package/dist/data-structures/binary-tree/tree-multiset.js +687 -34
- package/dist/data-structures/binary-tree/two-three-tree.js +2 -5
- package/dist/data-structures/graph/abstract-graph.d.ts +270 -36
- package/dist/data-structures/graph/abstract-graph.js +610 -572
- package/dist/data-structures/graph/directed-graph.d.ts +173 -16
- package/dist/data-structures/graph/directed-graph.js +345 -313
- 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 -9
- package/dist/data-structures/graph/undirected-graph.js +203 -178
- package/dist/data-structures/hash/coordinate-map.d.ts +38 -1
- package/dist/data-structures/hash/coordinate-map.js +59 -36
- package/dist/data-structures/hash/coordinate-set.d.ts +32 -2
- package/dist/data-structures/hash/coordinate-set.js +49 -33
- 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/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 -45
- package/dist/data-structures/heap/heap.js +124 -86
- package/dist/data-structures/heap/max-heap.d.ts +13 -5
- package/dist/data-structures/heap/max-heap.js +18 -28
- package/dist/data-structures/heap/min-heap.d.ts +14 -5
- package/dist/data-structures/heap/min-heap.js +19 -28
- package/dist/data-structures/index.d.ts +1 -1
- package/dist/data-structures/index.js +1 -1
- package/dist/data-structures/linked-list/doubly-linked-list.d.ts +193 -56
- package/dist/data-structures/linked-list/doubly-linked-list.js +484 -220
- 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 -315
- package/dist/data-structures/linked-list/singly-linked-list.js +374 -727
- 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 +21 -8
- package/dist/data-structures/matrix/matrix2d.d.ts +85 -2
- package/dist/data-structures/matrix/matrix2d.js +146 -80
- package/dist/data-structures/matrix/navigator.d.ts +36 -1
- package/dist/data-structures/matrix/navigator.js +46 -37
- package/dist/data-structures/matrix/vector2d.d.ts +142 -15
- package/dist/data-structures/matrix/vector2d.js +215 -109
- package/dist/data-structures/priority-queue/max-priority-queue.d.ts +12 -2
- package/dist/data-structures/priority-queue/max-priority-queue.js +33 -26
- package/dist/data-structures/priority-queue/min-priority-queue.d.ts +12 -2
- package/dist/data-structures/priority-queue/min-priority-queue.js +34 -26
- package/dist/data-structures/priority-queue/priority-queue.d.ts +153 -3
- package/dist/data-structures/priority-queue/priority-queue.js +244 -143
- package/dist/data-structures/queue/deque.d.ts +141 -13
- package/dist/data-structures/queue/deque.js +200 -82
- package/dist/data-structures/queue/queue.d.ts +65 -38
- package/dist/data-structures/queue/queue.js +110 -66
- package/dist/data-structures/stack/stack.d.ts +27 -32
- package/dist/data-structures/stack/stack.js +47 -53
- 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/data-structures/tree/tree.js +60 -0
- package/dist/data-structures/trie/trie.d.ts +33 -10
- package/dist/data-structures/trie/trie.js +123 -208
- 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-graph.d.ts +17 -0
- package/dist/interfaces/avl-tree.d.ts +9 -0
- package/dist/interfaces/binary-tree.d.ts +6 -0
- package/dist/interfaces/bst.d.ts +17 -0
- package/dist/interfaces/directed-graph.d.ts +12 -0
- package/{src/data-structures/types/index.ts → dist/interfaces/index.d.ts} +10 -8
- package/dist/interfaces/index.js +31 -0
- package/{src/data-structures/hash/hash-table.ts → dist/interfaces/priority-queue.d.ts} +1 -1
- package/dist/interfaces/rb-tree.d.ts +8 -0
- package/dist/interfaces/segment-tree.d.ts +1 -0
- package/dist/interfaces/singly-linked-list.d.ts +1 -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.d.ts +1 -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/{data-structures/types → types/data-structures}/index.d.ts +3 -1
- package/dist/{data-structures/types → types/data-structures}/index.js +3 -1
- package/dist/types/data-structures/map-graph.d.ts +1 -0
- package/dist/types/data-structures/map-graph.js +2 -0
- package/dist/{data-structures/types → types/data-structures}/navigator.d.ts +2 -2
- package/dist/types/data-structures/navigator.js +2 -0
- package/dist/{data-structures/types → types/data-structures}/priority-queue.d.ts +2 -2
- 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.js +2 -0
- package/dist/types/data-structures/singly-linked-list.d.ts +1 -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 +3 -0
- package/dist/types/index.js +19 -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/utils.d.ts +17 -103
- package/dist/utils/utils.js +40 -625
- package/package.json +134 -23
- 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 -16
- package/dist/data-structures/trampoline.js +0 -130
- package/dist/data-structures/types/abstract-graph.d.ts +0 -29
- package/dist/data-structures/types/avl-tree.d.ts +0 -5
- package/dist/data-structures/types/binary-tree.d.ts +0 -16
- package/dist/data-structures/types/bst.d.ts +0 -7
- package/dist/data-structures/types/directed-graph.d.ts +0 -10
- package/dist/data-structures/types/doubly-linked-list.d.ts +0 -1
- package/dist/data-structures/types/heap.d.ts +0 -7
- package/dist/data-structures/types/singly-linked-list.d.ts +0 -5
- package/dist/data-structures/types/tree-multiset.d.ts +0 -5
- package/dist/data-structures/types/utils.d.ts +0 -52
- package/dist/data-structures/types/utils.js +0 -54
- package/src/data-structures/binary-tree/aa-tree.ts +0 -3
- package/src/data-structures/binary-tree/avl-tree.ts +0 -227
- 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 -1133
- package/src/data-structures/binary-tree/bst.ts +0 -395
- package/src/data-structures/binary-tree/diagrams/avl-tree-inserting.gif +0 -0
- package/src/data-structures/binary-tree/diagrams/bst-rotation.gif +0 -0
- package/src/data-structures/binary-tree/diagrams/segment-tree.png +0 -0
- 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 -172
- package/src/data-structures/binary-tree/splay-tree.ts +0 -3
- package/src/data-structures/binary-tree/tree-multiset.ts +0 -18
- package/src/data-structures/binary-tree/two-three-tree.ts +0 -3
- package/src/data-structures/diagrams/README.md +0 -7
- package/src/data-structures/graph/abstract-graph.ts +0 -753
- package/src/data-structures/graph/diagrams/adjacency-list-pros-cons.png +0 -0
- package/src/data-structures/graph/diagrams/adjacency-list.png +0 -0
- package/src/data-structures/graph/diagrams/adjacency-matrix-pros-cons.png +0 -0
- package/src/data-structures/graph/diagrams/adjacency-matrix.png +0 -0
- package/src/data-structures/graph/diagrams/dfs-can-do.png +0 -0
- package/src/data-structures/graph/diagrams/edge-list-pros-cons.png +0 -0
- package/src/data-structures/graph/diagrams/edge-list.png +0 -0
- package/src/data-structures/graph/diagrams/max-flow.png +0 -0
- package/src/data-structures/graph/diagrams/mst.png +0 -0
- package/src/data-structures/graph/diagrams/tarjan-articulation-point-bridge.png +0 -0
- package/src/data-structures/graph/diagrams/tarjan-complicate-simple.png +0 -0
- package/src/data-structures/graph/diagrams/tarjan-strongly-connected-component.png +0 -0
- package/src/data-structures/graph/diagrams/tarjan.mp4 +0 -0
- package/src/data-structures/graph/directed-graph.ts +0 -306
- package/src/data-structures/graph/index.ts +0 -3
- package/src/data-structures/graph/undirected-graph.ts +0 -155
- 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/index.ts +0 -6
- package/src/data-structures/heap/heap.ts +0 -127
- package/src/data-structures/heap/index.ts +0 -3
- package/src/data-structures/heap/max-heap.ts +0 -23
- package/src/data-structures/heap/min-heap.ts +0 -25
- package/src/data-structures/index.ts +0 -12
- package/src/data-structures/linked-list/doubly-linked-list.ts +0 -250
- package/src/data-structures/linked-list/index.ts +0 -2
- package/src/data-structures/linked-list/singly-linked-list.ts +0 -736
- 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 -87
- 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 -13
- package/src/data-structures/priority-queue/min-priority-queue.ts +0 -13
- package/src/data-structures/priority-queue/priority-queue.ts +0 -200
- 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 -122
- package/src/data-structures/stack/index.ts +0 -1
- package/src/data-structures/stack/stack.ts +0 -103
- package/src/data-structures/trampoline.ts +0 -51
- package/src/data-structures/trie/index.ts +0 -1
- package/src/data-structures/trie/trie.ts +0 -203
- package/src/data-structures/types/abstract-graph.ts +0 -51
- package/src/data-structures/types/avl-tree.ts +0 -6
- package/src/data-structures/types/binary-tree.ts +0 -15
- package/src/data-structures/types/bst.ts +0 -5
- package/src/data-structures/types/directed-graph.ts +0 -18
- package/src/data-structures/types/doubly-linked-list.ts +0 -1
- package/src/data-structures/types/heap.ts +0 -8
- package/src/data-structures/types/navigator.ts +0 -12
- package/src/data-structures/types/priority-queue.ts +0 -9
- package/src/data-structures/types/segment-tree.ts +0 -1
- package/src/data-structures/types/singly-linked-list.ts +0 -15
- package/src/data-structures/types/tree-multiset.ts +0 -3
- package/src/data-structures/types/utils.ts +0 -173
- package/src/index.ts +0 -1
- package/src/utils/index.ts +0 -1
- package/src/utils/utils.ts +0 -505
- package/tsconfig.json +0 -56
- /package/dist/{data-structures/types/abstract-graph.js → interfaces/abstract-binary-tree.js} +0 -0
- /package/dist/{data-structures/types/avl-tree.js → interfaces/abstract-graph.js} +0 -0
- /package/dist/{data-structures/types/binary-tree.js → interfaces/avl-tree.js} +0 -0
- /package/dist/{data-structures/types/bst.js → interfaces/binary-tree.js} +0 -0
- /package/dist/{data-structures/types/directed-graph.js → interfaces/bst.js} +0 -0
- /package/dist/{data-structures/types/doubly-linked-list.js → interfaces/directed-graph.js} +0 -0
- /package/{src/data-structures/hash/pair.ts → dist/interfaces/doubly-linked-list.d.ts} +0 -0
- /package/dist/{data-structures/types/heap.js → interfaces/doubly-linked-list.js} +0 -0
- /package/{src/data-structures/hash/tree-map.ts → dist/interfaces/heap.d.ts} +0 -0
- /package/dist/{data-structures/types/navigator.js → interfaces/heap.js} +0 -0
- /package/{src/data-structures/hash/tree-set.ts → dist/interfaces/navigator.d.ts} +0 -0
- /package/dist/{data-structures/types/priority-queue.js → interfaces/navigator.js} +0 -0
- /package/dist/{data-structures/types/segment-tree.js → interfaces/priority-queue.js} +0 -0
- /package/dist/{data-structures/types/singly-linked-list.js → interfaces/rb-tree.js} +0 -0
- /package/dist/{data-structures/types/tree-multiset.js → interfaces/segment-tree.js} +0 -0
- /package/dist/{data-structures/types → types/data-structures}/segment-tree.d.ts +0 -0
package/package.json
CHANGED
|
@@ -1,54 +1,165 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "data-structure-typed",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.3.1",
|
|
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
|
-
"build": "rm -rf dist && npx tsc",
|
|
8
|
-
"
|
|
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"
|
|
9
16
|
},
|
|
10
17
|
"repository": {
|
|
11
18
|
"type": "git",
|
|
12
19
|
"url": "git+https://github.com/zrwusa/data-structure-typed.git"
|
|
13
20
|
},
|
|
14
21
|
"keywords": [
|
|
22
|
+
"data structure",
|
|
23
|
+
"Data Structure",
|
|
24
|
+
"data-structure",
|
|
25
|
+
"data structures",
|
|
26
|
+
"Data Structures",
|
|
27
|
+
"data-structures",
|
|
28
|
+
"algorithm",
|
|
29
|
+
"binary search tree",
|
|
30
|
+
"Binary Search Tree",
|
|
31
|
+
"binary-search-tree",
|
|
32
|
+
"binary tree",
|
|
15
33
|
"Binary Tree",
|
|
34
|
+
"binary-tree",
|
|
35
|
+
"bst",
|
|
36
|
+
"BST",
|
|
16
37
|
"AVL Tree",
|
|
17
|
-
"
|
|
38
|
+
"avl tree",
|
|
39
|
+
"avl-tree",
|
|
40
|
+
"avl",
|
|
41
|
+
"tree multiset",
|
|
18
42
|
"Tree Multiset",
|
|
19
|
-
"
|
|
20
|
-
"
|
|
43
|
+
"tree-multiset",
|
|
44
|
+
"Tree Multiset",
|
|
45
|
+
"dfs",
|
|
46
|
+
"DFS",
|
|
47
|
+
"dfs iterative",
|
|
48
|
+
"DFS Iterative",
|
|
49
|
+
"bfs",
|
|
50
|
+
"BFS",
|
|
51
|
+
"graph",
|
|
21
52
|
"Graph",
|
|
53
|
+
"directed graph",
|
|
22
54
|
"Directed Graph",
|
|
55
|
+
"directed-graph",
|
|
56
|
+
"undirected graph",
|
|
23
57
|
"Undirected Graph",
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"CoordinateSet",
|
|
27
|
-
"CoordinateMap",
|
|
58
|
+
"undirected-graph",
|
|
59
|
+
"heap",
|
|
28
60
|
"Heap",
|
|
29
|
-
"
|
|
61
|
+
"priority queue",
|
|
30
62
|
"Priority Queue",
|
|
63
|
+
"priority-queue",
|
|
64
|
+
"max priority queue",
|
|
31
65
|
"Max Priority Queue",
|
|
66
|
+
"max-priority-queue",
|
|
67
|
+
"min priority queue",
|
|
32
68
|
"Min Priority Queue",
|
|
69
|
+
"min-priority-queue",
|
|
70
|
+
"deque",
|
|
71
|
+
"Deque",
|
|
72
|
+
"linked list",
|
|
73
|
+
"Linked List",
|
|
74
|
+
"linked-list",
|
|
75
|
+
"trie",
|
|
76
|
+
"Trie",
|
|
77
|
+
"prefix tree",
|
|
78
|
+
"Prefix Tree",
|
|
79
|
+
"prefix-tree",
|
|
80
|
+
"binary",
|
|
81
|
+
"DataStructure",
|
|
82
|
+
"DataStructures",
|
|
83
|
+
"data",
|
|
84
|
+
"structure",
|
|
85
|
+
"sort",
|
|
86
|
+
"segment tree",
|
|
87
|
+
"Segment Tree",
|
|
88
|
+
"segment-tree",
|
|
89
|
+
"binary indexed tree",
|
|
90
|
+
"Binary Indexed Tree",
|
|
91
|
+
"binary-indexed-tree",
|
|
92
|
+
"linked list",
|
|
93
|
+
"Linked List",
|
|
94
|
+
"linked-list",
|
|
95
|
+
"singly linked list",
|
|
96
|
+
"Singly Linked List",
|
|
97
|
+
"singly-linked-list",
|
|
98
|
+
"doubly linked list",
|
|
99
|
+
"Doubly Linked List",
|
|
100
|
+
"doubly-linked-list",
|
|
101
|
+
"queue",
|
|
102
|
+
"array queue",
|
|
103
|
+
"Array Queue",
|
|
104
|
+
"array-queue",
|
|
33
105
|
"Queue",
|
|
34
|
-
"
|
|
35
|
-
"
|
|
106
|
+
"object deque",
|
|
107
|
+
"Object Deque",
|
|
108
|
+
"array deque",
|
|
109
|
+
"Array Deque",
|
|
110
|
+
"stack",
|
|
36
111
|
"Stack",
|
|
37
|
-
"
|
|
112
|
+
"hash",
|
|
113
|
+
"Hash",
|
|
114
|
+
"morris",
|
|
115
|
+
"Morris",
|
|
116
|
+
"bellman ford",
|
|
117
|
+
"Bellman Ford",
|
|
118
|
+
"bellman-ford",
|
|
119
|
+
"dijkstra",
|
|
120
|
+
"Dijkstra",
|
|
121
|
+
"floyd warshall",
|
|
122
|
+
"Floyd Warshall",
|
|
123
|
+
"floyd-warshall",
|
|
124
|
+
"Tarjan",
|
|
125
|
+
"tarjan",
|
|
126
|
+
"Tarjan's"
|
|
38
127
|
],
|
|
39
|
-
"author": "Tyler Zeng",
|
|
40
|
-
"license": "
|
|
128
|
+
"author": "Tyler Zeng zrwusa@gmail.com",
|
|
129
|
+
"license": "MIT",
|
|
41
130
|
"bugs": {
|
|
42
131
|
"url": "https://github.com/zrwusa/data-structure-typed/issues"
|
|
43
132
|
},
|
|
44
133
|
"homepage": "https://github.com/zrwusa/data-structure-typed#readme",
|
|
45
|
-
"types": "dist/index.d.ts",
|
|
46
134
|
"devDependencies": {
|
|
47
|
-
"@types/
|
|
135
|
+
"@types/jest": "^29.5.3",
|
|
48
136
|
"@types/node": "^20.4.9",
|
|
49
|
-
"
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
"
|
|
137
|
+
"avl-tree-typed": "^1.21.3",
|
|
138
|
+
"binary-tree-typed": "^1.21.3",
|
|
139
|
+
"bst-typed": "^1.21.3",
|
|
140
|
+
"dependency-cruiser": "^13.1.2",
|
|
141
|
+
"deque-typed": "^1.21.3",
|
|
142
|
+
"directed-graph-typed": "^1.21.3",
|
|
143
|
+
"doubly-linked-list-typed": "^1.21.3",
|
|
144
|
+
"graph-typed": "^1.21.3",
|
|
145
|
+
"heap-typed": "^1.21.3",
|
|
146
|
+
"jest": "^29.6.2",
|
|
147
|
+
"linked-list-typed": "^1.21.3",
|
|
148
|
+
"max-heap-typed": "^1.21.3",
|
|
149
|
+
"max-priority-queue-typed": "^1.21.3",
|
|
150
|
+
"min-heap-typed": "^1.21.3",
|
|
151
|
+
"min-priority-queue-typed": "^1.21.3",
|
|
152
|
+
"priority-queue-typed": "^1.21.3",
|
|
153
|
+
"singly-linked-list-typed": "^1.21.3",
|
|
154
|
+
"stack-typed": "^1.21.3",
|
|
155
|
+
"tree-multiset-typed": "^1.21.3",
|
|
156
|
+
"trie-typed": "^1.21.3",
|
|
157
|
+
"ts-jest": "^29.1.1",
|
|
158
|
+
"ts-loader": "^9.4.4",
|
|
159
|
+
"typedoc": "^0.24.8",
|
|
160
|
+
"typescript": "^4.9.5",
|
|
161
|
+
"undirected-graph-typed": "^1.21.3",
|
|
162
|
+
"webpack": "^5.88.2",
|
|
163
|
+
"webpack-cli": "^5.1.4"
|
|
53
164
|
}
|
|
54
165
|
}
|
|
@@ -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-typed.iml" filepath="$PROJECT_DIR$/.idea/data-structure-typed.iml" />
|
|
6
|
-
</modules>
|
|
7
|
-
</component>
|
|
8
|
-
</project>
|
package/.idea/vcs.xml
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export declare const THUNK_SYMBOL: unique symbol;
|
|
2
|
-
export declare const isThunk: (fnOrValue: any) => boolean;
|
|
3
|
-
type ToThunkFn = () => ReturnType<TrlFn>;
|
|
4
|
-
type Thunk = () => ReturnType<ToThunkFn> & {
|
|
5
|
-
__THUNK__: typeof THUNK_SYMBOL;
|
|
6
|
-
};
|
|
7
|
-
export declare const toThunk: (fn: ToThunkFn) => Thunk;
|
|
8
|
-
type TrlFn = (...args: any[]) => any;
|
|
9
|
-
export declare const trampoline: (fn: TrlFn) => ((...args: [...Parameters<TrlFn>]) => any) & {
|
|
10
|
-
cont: (...args: [...Parameters<TrlFn>]) => Thunk;
|
|
11
|
-
};
|
|
12
|
-
type TrlAsyncFn = (...args: any[]) => any;
|
|
13
|
-
export declare const trampolineAsync: (fn: TrlAsyncFn) => ((...args: [...Parameters<TrlAsyncFn>]) => Promise<any>) & {
|
|
14
|
-
cont: (...args: [...Parameters<TrlAsyncFn>]) => Thunk;
|
|
15
|
-
};
|
|
16
|
-
export {};
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
39
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
40
|
-
if (!m) return o;
|
|
41
|
-
var i = m.call(o), r, ar = [], e;
|
|
42
|
-
try {
|
|
43
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
44
|
-
}
|
|
45
|
-
catch (error) { e = { error: error }; }
|
|
46
|
-
finally {
|
|
47
|
-
try {
|
|
48
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
49
|
-
}
|
|
50
|
-
finally { if (e) throw e.error; }
|
|
51
|
-
}
|
|
52
|
-
return ar;
|
|
53
|
-
};
|
|
54
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
55
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
56
|
-
if (ar || !(i in from)) {
|
|
57
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
58
|
-
ar[i] = from[i];
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
62
|
-
};
|
|
63
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
64
|
-
exports.trampolineAsync = exports.trampoline = exports.toThunk = exports.isThunk = exports.THUNK_SYMBOL = void 0;
|
|
65
|
-
exports.THUNK_SYMBOL = Symbol('thunk');
|
|
66
|
-
var isThunk = function (fnOrValue) {
|
|
67
|
-
return typeof fnOrValue === 'function' && fnOrValue.__THUNK__ === exports.THUNK_SYMBOL;
|
|
68
|
-
};
|
|
69
|
-
exports.isThunk = isThunk;
|
|
70
|
-
var toThunk = function (fn) {
|
|
71
|
-
var thunk = function () { return fn(); };
|
|
72
|
-
thunk.__THUNK__ = exports.THUNK_SYMBOL;
|
|
73
|
-
return thunk;
|
|
74
|
-
};
|
|
75
|
-
exports.toThunk = toThunk;
|
|
76
|
-
var trampoline = function (fn) {
|
|
77
|
-
var cont = function () {
|
|
78
|
-
var args = [];
|
|
79
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
80
|
-
args[_i] = arguments[_i];
|
|
81
|
-
}
|
|
82
|
-
return (0, exports.toThunk)(function () { return fn.apply(void 0, __spreadArray([], __read(args), false)); });
|
|
83
|
-
};
|
|
84
|
-
return Object.assign(function () {
|
|
85
|
-
var args = [];
|
|
86
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
87
|
-
args[_i] = arguments[_i];
|
|
88
|
-
}
|
|
89
|
-
var result = fn.apply(void 0, __spreadArray([], __read(args), false));
|
|
90
|
-
while ((0, exports.isThunk)(result) && typeof result === 'function') {
|
|
91
|
-
result = result();
|
|
92
|
-
}
|
|
93
|
-
return result;
|
|
94
|
-
}, { cont: cont });
|
|
95
|
-
};
|
|
96
|
-
exports.trampoline = trampoline;
|
|
97
|
-
var trampolineAsync = function (fn) {
|
|
98
|
-
var cont = function () {
|
|
99
|
-
var args = [];
|
|
100
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
101
|
-
args[_i] = arguments[_i];
|
|
102
|
-
}
|
|
103
|
-
return (0, exports.toThunk)(function () { return fn.apply(void 0, __spreadArray([], __read(args), false)); });
|
|
104
|
-
};
|
|
105
|
-
return Object.assign(function () {
|
|
106
|
-
var args = [];
|
|
107
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
108
|
-
args[_i] = arguments[_i];
|
|
109
|
-
}
|
|
110
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
111
|
-
var result;
|
|
112
|
-
return __generator(this, function (_a) {
|
|
113
|
-
switch (_a.label) {
|
|
114
|
-
case 0: return [4 /*yield*/, fn.apply(void 0, __spreadArray([], __read(args), false))];
|
|
115
|
-
case 1:
|
|
116
|
-
result = _a.sent();
|
|
117
|
-
_a.label = 2;
|
|
118
|
-
case 2:
|
|
119
|
-
if (!((0, exports.isThunk)(result) && typeof result === 'function')) return [3 /*break*/, 4];
|
|
120
|
-
return [4 /*yield*/, result()];
|
|
121
|
-
case 3:
|
|
122
|
-
result = _a.sent();
|
|
123
|
-
return [3 /*break*/, 2];
|
|
124
|
-
case 4: return [2 /*return*/, result];
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
});
|
|
128
|
-
}, { cont: cont });
|
|
129
|
-
};
|
|
130
|
-
exports.trampolineAsync = trampolineAsync;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
export type VertexId = string | number;
|
|
2
|
-
export type DijkstraResult<V> = {
|
|
3
|
-
distMap: Map<V, number>;
|
|
4
|
-
preMap: Map<V, V | null>;
|
|
5
|
-
seen: Set<V>;
|
|
6
|
-
paths: V[][];
|
|
7
|
-
minDist: number;
|
|
8
|
-
minPath: V[];
|
|
9
|
-
} | null;
|
|
10
|
-
export interface IGraph<V, E> {
|
|
11
|
-
containsVertex(vertexOrId: V | VertexId): boolean;
|
|
12
|
-
getVertex(vertexOrId: VertexId | V): V | null;
|
|
13
|
-
getVertexId(vertexOrId: V | VertexId): VertexId;
|
|
14
|
-
vertexSet(): Map<VertexId, V>;
|
|
15
|
-
addVertex(v: V): boolean;
|
|
16
|
-
removeVertex(vertexOrId: V | VertexId): boolean;
|
|
17
|
-
removeAllVertices(vertices: V[] | VertexId[]): boolean;
|
|
18
|
-
degreeOf(vertexOrId: V | VertexId): number;
|
|
19
|
-
edgesOf(vertexOrId: V | VertexId): E[];
|
|
20
|
-
containsEdge(src: V | VertexId, dest: V | VertexId): boolean;
|
|
21
|
-
getEdge(srcOrId: V | VertexId, destOrId: V | VertexId): E | null;
|
|
22
|
-
edgeSet(): E[];
|
|
23
|
-
addEdge(edge: E): boolean;
|
|
24
|
-
removeEdgeBetween(srcOrId: V | VertexId, destOrId: V | VertexId): E | null;
|
|
25
|
-
removeEdge(edge: E): E | null;
|
|
26
|
-
setEdgeWeight(srcOrId: V | VertexId, destOrId: V | VertexId, weight: number): boolean;
|
|
27
|
-
getMinPathBetween(v1: V | VertexId, v2: V | VertexId, isWeight?: boolean): V[] | null;
|
|
28
|
-
getNeighbors(vertexOrId: V | VertexId): V[];
|
|
29
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { BinaryTreeNode } from "../binary-tree";
|
|
2
|
-
export type BinaryTreeNodePropertyName = 'id' | 'val' | 'count';
|
|
3
|
-
export type NodeOrPropertyName = 'node' | BinaryTreeNodePropertyName;
|
|
4
|
-
export type DFSOrderPattern = 'in' | 'pre' | 'post';
|
|
5
|
-
export type BinaryTreeNodeId = number;
|
|
6
|
-
export type BinaryTreeDeleted<T> = {
|
|
7
|
-
deleted: BinaryTreeNode<T> | null | undefined;
|
|
8
|
-
needBalanced: BinaryTreeNode<T> | null;
|
|
9
|
-
};
|
|
10
|
-
export type ResultByProperty<T> = T | BinaryTreeNode<T> | number | BinaryTreeNodeId;
|
|
11
|
-
export type ResultsByProperty<T> = ResultByProperty<T>[];
|
|
12
|
-
export interface BinaryTreeNodeObj<T> {
|
|
13
|
-
id: BinaryTreeNodeId;
|
|
14
|
-
val: T;
|
|
15
|
-
count?: number;
|
|
16
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { BSTNode } from '../binary-tree';
|
|
2
|
-
import type { BinaryTreeNodeId } from './binary-tree';
|
|
3
|
-
export type BSTComparator = (a: BinaryTreeNodeId, b: BinaryTreeNodeId) => number;
|
|
4
|
-
export type BSTDeletedResult<T> = {
|
|
5
|
-
deleted: BSTNode<T> | null;
|
|
6
|
-
needBalanced: BSTNode<T> | null;
|
|
7
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { VertexId } from './abstract-graph';
|
|
2
|
-
export interface IDirectedGraph<V, E> {
|
|
3
|
-
incomingEdgesOf(vertex: V): E[];
|
|
4
|
-
outgoingEdgesOf(vertex: V): E[];
|
|
5
|
-
inDegreeOf(vertexOrId: V | VertexId): number;
|
|
6
|
-
outDegreeOf(vertexOrId: V | VertexId): number;
|
|
7
|
-
getEdgeSrc(e: E): V | null;
|
|
8
|
-
getEdgeDest(e: E): V | null;
|
|
9
|
-
}
|
|
10
|
-
export type TopologicalStatus = 0 | 1 | 2;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type DoublyLinkedListGetBy = 'node' | 'val';
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { SinglyLinkedList } from "../linked-list";
|
|
2
|
-
/** Type used for filter and find methods, returning a boolean */
|
|
3
|
-
export type TTestFunction<NodeData> = (data: NodeData, index: number, list: SinglyLinkedList<NodeData>) => boolean;
|
|
4
|
-
/** Type used for map and forEach methods, returning anything */
|
|
5
|
-
export type TMapFunction<NodeData> = (data: any, index: number, list: SinglyLinkedList<NodeData>) => any;
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
export type AnyFunction<A extends any[] = any[], R = any> = (...args: A) => R;
|
|
2
|
-
export type Primitive = number | string | boolean | symbol | undefined | null | void | AnyFunction | Date;
|
|
3
|
-
export type Cast<T, TComplex> = {
|
|
4
|
-
[M in keyof TComplex]: T;
|
|
5
|
-
};
|
|
6
|
-
export type DeepLeavesWrap<T, TComplex> = T extends string ? Cast<string, TComplex> : T extends number ? Cast<number, TComplex> : T extends boolean ? Cast<boolean, TComplex> : T extends undefined ? Cast<undefined, TComplex> : T extends null ? Cast<null, TComplex> : T extends void ? Cast<void, TComplex> : T extends symbol ? Cast<symbol, TComplex> : T extends AnyFunction ? Cast<AnyFunction, TComplex> : T extends Date ? Cast<Date, TComplex> : {
|
|
7
|
-
[K in keyof T]: T[K] extends (infer U)[] ? DeepLeavesWrap<U, TComplex>[] : DeepLeavesWrap<T[K], TComplex>;
|
|
8
|
-
};
|
|
9
|
-
export type JSONSerializable = {
|
|
10
|
-
[key: string]: any;
|
|
11
|
-
};
|
|
12
|
-
export type JSONValue = string | number | boolean | undefined | JSONObject;
|
|
13
|
-
export interface JSONObject {
|
|
14
|
-
[key: string]: JSONValue;
|
|
15
|
-
}
|
|
16
|
-
export type TypeName<T> = T extends string ? 'string' : T extends number ? 'number' : T extends boolean ? 'boolean' : T extends undefined ? 'undefined' : T extends AnyFunction ? 'function' : 'object';
|
|
17
|
-
export type JsonKeys<T> = keyof {
|
|
18
|
-
[P in keyof T]: number;
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* A function that emits a side effect and does not return anything.
|
|
22
|
-
*/
|
|
23
|
-
export type Procedure = (...args: any[]) => void;
|
|
24
|
-
export type DebounceOptions = {
|
|
25
|
-
isImmediate?: boolean;
|
|
26
|
-
maxWait?: number;
|
|
27
|
-
};
|
|
28
|
-
export interface DebouncedFunction<F extends Procedure> {
|
|
29
|
-
cancel: () => void;
|
|
30
|
-
(this: ThisParameterType<F>, ...args: [...Parameters<F>]): void;
|
|
31
|
-
}
|
|
32
|
-
export type MonthKey = 'January' | 'February' | 'March' | 'April' | 'May' | 'June' | 'July' | 'August' | 'September' | 'October' | 'November' | 'December';
|
|
33
|
-
export type Month = {
|
|
34
|
-
[key in MonthKey]: string;
|
|
35
|
-
};
|
|
36
|
-
export type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
|
|
37
|
-
export declare class TreeNode<T> {
|
|
38
|
-
id: string;
|
|
39
|
-
name?: string | undefined;
|
|
40
|
-
value?: T | undefined;
|
|
41
|
-
children?: TreeNode<T>[] | undefined;
|
|
42
|
-
constructor(id: string, name?: string, value?: T, children?: TreeNode<T>[]);
|
|
43
|
-
addChildren(children: TreeNode<T> | TreeNode<T>[]): void;
|
|
44
|
-
getHeight(): number;
|
|
45
|
-
}
|
|
46
|
-
export type OrderType = 'InOrder' | 'PreOrder' | 'PostOrder';
|
|
47
|
-
export type DeepProxy<T> = T extends (...args: any[]) => infer R ? (...args: [...Parameters<T>]) => DeepProxy<R> : T extends object ? {
|
|
48
|
-
[K in keyof T]: DeepProxy<T[K]>;
|
|
49
|
-
} : T;
|
|
50
|
-
export type DeepProxyOnChange = (target: any, property: string | symbol, value: any, receiver: any, descriptor: any, result: any) => void;
|
|
51
|
-
export type DeepProxyOnGet = (target: any, property: string | symbol, value: any, receiver: any, descriptor: any, result: any) => void;
|
|
52
|
-
export type CurryFunc<T> = T extends (...args: infer Args) => infer R ? Args extends [infer Arg, ...infer RestArgs] ? (arg: Arg) => CurryFunc<(...args: RestArgs) => R> : R : T;
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TreeNode = void 0;
|
|
4
|
-
var arr = ['1', 2, 4, 5, 6];
|
|
5
|
-
var a = 2;
|
|
6
|
-
var TreeNode = /** @class */ (function () {
|
|
7
|
-
function TreeNode(id, name, value, children) {
|
|
8
|
-
this.id = id;
|
|
9
|
-
this.name = name || '';
|
|
10
|
-
this.value = value || undefined;
|
|
11
|
-
this.children = children || [];
|
|
12
|
-
}
|
|
13
|
-
// TODO get set
|
|
14
|
-
// get name (): string | undefined {
|
|
15
|
-
// return this.name;
|
|
16
|
-
// }
|
|
17
|
-
//
|
|
18
|
-
// set name (name: string | undefined) {
|
|
19
|
-
// this.name = name;
|
|
20
|
-
// }
|
|
21
|
-
TreeNode.prototype.addChildren = function (children) {
|
|
22
|
-
if (!this.children) {
|
|
23
|
-
this.children = [];
|
|
24
|
-
}
|
|
25
|
-
if (children instanceof TreeNode) {
|
|
26
|
-
this.children.push(children);
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
this.children = this.children.concat(children);
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
TreeNode.prototype.getHeight = function () {
|
|
33
|
-
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
34
|
-
var beginRoot = this;
|
|
35
|
-
var maxDepth = 1;
|
|
36
|
-
if (beginRoot) {
|
|
37
|
-
var bfs_1 = function (node, level) {
|
|
38
|
-
if (level > maxDepth) {
|
|
39
|
-
maxDepth = level;
|
|
40
|
-
}
|
|
41
|
-
var children = node.children;
|
|
42
|
-
if (children) {
|
|
43
|
-
for (var i = 0, len = children.length; i < len; i++) {
|
|
44
|
-
bfs_1(children[i], level + 1);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
bfs_1(beginRoot, 1);
|
|
49
|
-
}
|
|
50
|
-
return maxDepth;
|
|
51
|
-
};
|
|
52
|
-
return TreeNode;
|
|
53
|
-
}());
|
|
54
|
-
exports.TreeNode = TreeNode;
|