data-structure-typed 0.9.16 → 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.
Files changed (264) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +665 -172
  3. package/dist/bundle.js +2 -0
  4. package/dist/bundle.js.LICENSE.txt +13 -0
  5. package/dist/data-structures/binary-tree/aa-tree.js +2 -5
  6. package/dist/data-structures/binary-tree/abstract-binary-tree.d.ts +364 -0
  7. package/dist/data-structures/binary-tree/abstract-binary-tree.js +1308 -0
  8. package/dist/data-structures/binary-tree/avl-tree.d.ts +85 -14
  9. package/dist/data-structures/binary-tree/avl-tree.js +142 -116
  10. package/dist/data-structures/binary-tree/b-tree.js +2 -5
  11. package/dist/data-structures/binary-tree/binary-indexed-tree.d.ts +39 -1
  12. package/dist/data-structures/binary-tree/binary-indexed-tree.js +54 -13
  13. package/dist/data-structures/binary-tree/binary-tree.d.ts +29 -126
  14. package/dist/data-structures/binary-tree/binary-tree.js +31 -1093
  15. package/dist/data-structures/binary-tree/bst.d.ts +117 -23
  16. package/dist/data-structures/binary-tree/bst.js +233 -240
  17. package/dist/data-structures/binary-tree/index.d.ts +1 -0
  18. package/dist/data-structures/binary-tree/index.js +1 -0
  19. package/dist/data-structures/binary-tree/rb-tree.d.ts +18 -1
  20. package/dist/data-structures/binary-tree/rb-tree.js +40 -5
  21. package/dist/data-structures/binary-tree/segment-tree.d.ts +61 -11
  22. package/dist/data-structures/binary-tree/segment-tree.js +126 -93
  23. package/dist/data-structures/binary-tree/splay-tree.js +2 -5
  24. package/dist/data-structures/binary-tree/tree-multiset.d.ts +213 -6
  25. package/dist/data-structures/binary-tree/tree-multiset.js +687 -34
  26. package/dist/data-structures/binary-tree/two-three-tree.js +2 -5
  27. package/dist/data-structures/graph/abstract-graph.d.ts +270 -36
  28. package/dist/data-structures/graph/abstract-graph.js +610 -572
  29. package/dist/data-structures/graph/directed-graph.d.ts +173 -16
  30. package/dist/data-structures/graph/directed-graph.js +345 -313
  31. package/dist/data-structures/graph/index.d.ts +1 -0
  32. package/dist/data-structures/graph/index.js +1 -0
  33. package/dist/data-structures/graph/map-graph.d.ts +79 -0
  34. package/dist/data-structures/graph/map-graph.js +111 -0
  35. package/dist/data-structures/graph/undirected-graph.d.ts +111 -9
  36. package/dist/data-structures/graph/undirected-graph.js +203 -178
  37. package/dist/data-structures/hash/coordinate-map.d.ts +38 -1
  38. package/dist/data-structures/hash/coordinate-map.js +59 -36
  39. package/dist/data-structures/hash/coordinate-set.d.ts +32 -2
  40. package/dist/data-structures/hash/coordinate-set.js +49 -33
  41. package/dist/data-structures/hash/hash-table.d.ts +2 -1
  42. package/dist/data-structures/hash/hash-table.js +4 -0
  43. package/dist/data-structures/hash/pair.d.ts +2 -1
  44. package/dist/data-structures/hash/pair.js +4 -0
  45. package/dist/data-structures/hash/tree-map.d.ts +2 -1
  46. package/dist/data-structures/hash/tree-map.js +4 -0
  47. package/dist/data-structures/hash/tree-set.d.ts +2 -1
  48. package/dist/data-structures/hash/tree-set.js +4 -0
  49. package/dist/data-structures/heap/heap.d.ts +62 -45
  50. package/dist/data-structures/heap/heap.js +124 -86
  51. package/dist/data-structures/heap/max-heap.d.ts +13 -5
  52. package/dist/data-structures/heap/max-heap.js +18 -28
  53. package/dist/data-structures/heap/min-heap.d.ts +14 -5
  54. package/dist/data-structures/heap/min-heap.js +19 -28
  55. package/dist/data-structures/index.d.ts +1 -1
  56. package/dist/data-structures/index.js +1 -1
  57. package/dist/data-structures/linked-list/doubly-linked-list.d.ts +193 -56
  58. package/dist/data-structures/linked-list/doubly-linked-list.js +484 -220
  59. package/dist/data-structures/linked-list/index.d.ts +1 -0
  60. package/dist/data-structures/linked-list/index.js +1 -0
  61. package/dist/data-structures/linked-list/singly-linked-list.d.ts +117 -315
  62. package/dist/data-structures/linked-list/singly-linked-list.js +374 -727
  63. package/dist/data-structures/linked-list/skip-linked-list.d.ts +2 -1
  64. package/dist/data-structures/linked-list/skip-linked-list.js +4 -0
  65. package/dist/data-structures/matrix/matrix.d.ts +12 -0
  66. package/dist/data-structures/matrix/matrix.js +21 -8
  67. package/dist/data-structures/matrix/matrix2d.d.ts +85 -2
  68. package/dist/data-structures/matrix/matrix2d.js +146 -80
  69. package/dist/data-structures/matrix/navigator.d.ts +36 -1
  70. package/dist/data-structures/matrix/navigator.js +46 -37
  71. package/dist/data-structures/matrix/vector2d.d.ts +142 -15
  72. package/dist/data-structures/matrix/vector2d.js +215 -109
  73. package/dist/data-structures/priority-queue/max-priority-queue.d.ts +12 -2
  74. package/dist/data-structures/priority-queue/max-priority-queue.js +33 -26
  75. package/dist/data-structures/priority-queue/min-priority-queue.d.ts +12 -2
  76. package/dist/data-structures/priority-queue/min-priority-queue.js +34 -26
  77. package/dist/data-structures/priority-queue/priority-queue.d.ts +153 -3
  78. package/dist/data-structures/priority-queue/priority-queue.js +244 -143
  79. package/dist/data-structures/queue/deque.d.ts +141 -13
  80. package/dist/data-structures/queue/deque.js +200 -82
  81. package/dist/data-structures/queue/queue.d.ts +65 -38
  82. package/dist/data-structures/queue/queue.js +110 -66
  83. package/dist/data-structures/stack/stack.d.ts +27 -32
  84. package/dist/data-structures/stack/stack.js +47 -53
  85. package/dist/data-structures/tree/index.d.ts +1 -0
  86. package/dist/data-structures/tree/index.js +17 -0
  87. package/dist/data-structures/tree/tree.d.ts +14 -0
  88. package/dist/data-structures/tree/tree.js +60 -0
  89. package/dist/data-structures/trie/trie.d.ts +33 -10
  90. package/dist/data-structures/trie/trie.js +123 -208
  91. package/dist/index.d.ts +3 -0
  92. package/dist/index.js +3 -0
  93. package/dist/interfaces/abstract-binary-tree.d.ts +90 -0
  94. package/dist/interfaces/abstract-graph.d.ts +17 -0
  95. package/dist/interfaces/avl-tree.d.ts +9 -0
  96. package/dist/interfaces/binary-tree.d.ts +6 -0
  97. package/dist/interfaces/bst.d.ts +17 -0
  98. package/dist/interfaces/directed-graph.d.ts +12 -0
  99. package/{src/data-structures/types/index.ts → dist/interfaces/index.d.ts} +10 -8
  100. package/dist/interfaces/index.js +31 -0
  101. package/{src/data-structures/hash/hash-table.ts → dist/interfaces/priority-queue.d.ts} +1 -1
  102. package/dist/interfaces/rb-tree.d.ts +8 -0
  103. package/dist/interfaces/segment-tree.d.ts +1 -0
  104. package/dist/interfaces/singly-linked-list.d.ts +1 -0
  105. package/dist/interfaces/singly-linked-list.js +2 -0
  106. package/dist/interfaces/tree-multiset.d.ts +7 -0
  107. package/dist/interfaces/tree-multiset.js +2 -0
  108. package/dist/interfaces/undirected-graph.d.ts +5 -0
  109. package/dist/interfaces/undirected-graph.js +2 -0
  110. package/dist/types/data-structures/abstract-binary-tree.d.ts +34 -0
  111. package/dist/types/data-structures/abstract-binary-tree.js +25 -0
  112. package/dist/types/data-structures/abstract-graph.d.ts +11 -0
  113. package/dist/types/data-structures/abstract-graph.js +2 -0
  114. package/dist/types/data-structures/avl-tree.d.ts +4 -0
  115. package/dist/types/data-structures/avl-tree.js +2 -0
  116. package/dist/types/data-structures/binary-tree.d.ts +4 -0
  117. package/dist/types/data-structures/binary-tree.js +2 -0
  118. package/dist/types/data-structures/bst.d.ts +13 -0
  119. package/dist/types/data-structures/bst.js +9 -0
  120. package/dist/types/data-structures/directed-graph.d.ts +6 -0
  121. package/dist/types/data-structures/directed-graph.js +9 -0
  122. package/dist/types/data-structures/doubly-linked-list.d.ts +1 -0
  123. package/dist/types/data-structures/doubly-linked-list.js +2 -0
  124. package/dist/types/data-structures/heap.d.ts +3 -0
  125. package/dist/types/data-structures/heap.js +2 -0
  126. package/dist/{data-structures/types → types/data-structures}/index.d.ts +3 -1
  127. package/dist/{data-structures/types → types/data-structures}/index.js +3 -1
  128. package/dist/types/data-structures/map-graph.d.ts +1 -0
  129. package/dist/types/data-structures/map-graph.js +2 -0
  130. package/dist/{data-structures/types → types/data-structures}/navigator.d.ts +2 -2
  131. package/dist/types/data-structures/navigator.js +2 -0
  132. package/dist/{data-structures/types → types/data-structures}/priority-queue.d.ts +2 -2
  133. package/dist/types/data-structures/priority-queue.js +2 -0
  134. package/dist/types/data-structures/rb-tree.d.ts +8 -0
  135. package/dist/types/data-structures/rb-tree.js +8 -0
  136. package/dist/types/data-structures/segment-tree.js +2 -0
  137. package/dist/types/data-structures/singly-linked-list.d.ts +1 -0
  138. package/dist/types/data-structures/singly-linked-list.js +2 -0
  139. package/dist/types/data-structures/tree-multiset.d.ts +4 -0
  140. package/dist/types/data-structures/tree-multiset.js +2 -0
  141. package/dist/types/helpers.d.ts +1 -0
  142. package/dist/types/helpers.js +2 -0
  143. package/dist/types/index.d.ts +3 -0
  144. package/dist/types/index.js +19 -0
  145. package/dist/types/utils/index.d.ts +2 -0
  146. package/dist/types/utils/index.js +18 -0
  147. package/dist/types/utils/utils.d.ts +7 -0
  148. package/dist/types/utils/utils.js +2 -0
  149. package/dist/types/utils/validate-type.d.ts +19 -0
  150. package/dist/types/utils/validate-type.js +2 -0
  151. package/dist/utils/utils.d.ts +17 -103
  152. package/dist/utils/utils.js +40 -625
  153. package/package.json +96 -23
  154. package/.idea/data-structure-typed.iml +0 -12
  155. package/.idea/modules.xml +0 -8
  156. package/.idea/vcs.xml +0 -6
  157. package/dist/data-structures/trampoline.d.ts +0 -16
  158. package/dist/data-structures/trampoline.js +0 -130
  159. package/dist/data-structures/types/abstract-graph.d.ts +0 -29
  160. package/dist/data-structures/types/avl-tree.d.ts +0 -5
  161. package/dist/data-structures/types/binary-tree.d.ts +0 -16
  162. package/dist/data-structures/types/bst.d.ts +0 -7
  163. package/dist/data-structures/types/directed-graph.d.ts +0 -10
  164. package/dist/data-structures/types/doubly-linked-list.d.ts +0 -1
  165. package/dist/data-structures/types/heap.d.ts +0 -7
  166. package/dist/data-structures/types/singly-linked-list.d.ts +0 -5
  167. package/dist/data-structures/types/tree-multiset.d.ts +0 -5
  168. package/dist/data-structures/types/utils.d.ts +0 -52
  169. package/dist/data-structures/types/utils.js +0 -54
  170. package/src/data-structures/binary-tree/aa-tree.ts +0 -3
  171. package/src/data-structures/binary-tree/avl-tree.ts +0 -227
  172. package/src/data-structures/binary-tree/b-tree.ts +0 -3
  173. package/src/data-structures/binary-tree/binary-indexed-tree.ts +0 -33
  174. package/src/data-structures/binary-tree/binary-tree.ts +0 -1133
  175. package/src/data-structures/binary-tree/bst.ts +0 -395
  176. package/src/data-structures/binary-tree/diagrams/avl-tree-inserting.gif +0 -0
  177. package/src/data-structures/binary-tree/diagrams/bst-rotation.gif +0 -0
  178. package/src/data-structures/binary-tree/diagrams/segment-tree.png +0 -0
  179. package/src/data-structures/binary-tree/index.ts +0 -11
  180. package/src/data-structures/binary-tree/rb-tree.ts +0 -3
  181. package/src/data-structures/binary-tree/segment-tree.ts +0 -172
  182. package/src/data-structures/binary-tree/splay-tree.ts +0 -3
  183. package/src/data-structures/binary-tree/tree-multiset.ts +0 -18
  184. package/src/data-structures/binary-tree/two-three-tree.ts +0 -3
  185. package/src/data-structures/diagrams/README.md +0 -7
  186. package/src/data-structures/graph/abstract-graph.ts +0 -753
  187. package/src/data-structures/graph/diagrams/adjacency-list-pros-cons.png +0 -0
  188. package/src/data-structures/graph/diagrams/adjacency-list.png +0 -0
  189. package/src/data-structures/graph/diagrams/adjacency-matrix-pros-cons.png +0 -0
  190. package/src/data-structures/graph/diagrams/adjacency-matrix.png +0 -0
  191. package/src/data-structures/graph/diagrams/dfs-can-do.png +0 -0
  192. package/src/data-structures/graph/diagrams/edge-list-pros-cons.png +0 -0
  193. package/src/data-structures/graph/diagrams/edge-list.png +0 -0
  194. package/src/data-structures/graph/diagrams/max-flow.png +0 -0
  195. package/src/data-structures/graph/diagrams/mst.png +0 -0
  196. package/src/data-structures/graph/diagrams/tarjan-articulation-point-bridge.png +0 -0
  197. package/src/data-structures/graph/diagrams/tarjan-complicate-simple.png +0 -0
  198. package/src/data-structures/graph/diagrams/tarjan-strongly-connected-component.png +0 -0
  199. package/src/data-structures/graph/diagrams/tarjan.mp4 +0 -0
  200. package/src/data-structures/graph/directed-graph.ts +0 -306
  201. package/src/data-structures/graph/index.ts +0 -3
  202. package/src/data-structures/graph/undirected-graph.ts +0 -155
  203. package/src/data-structures/hash/coordinate-map.ts +0 -24
  204. package/src/data-structures/hash/coordinate-set.ts +0 -20
  205. package/src/data-structures/hash/index.ts +0 -6
  206. package/src/data-structures/heap/heap.ts +0 -127
  207. package/src/data-structures/heap/index.ts +0 -3
  208. package/src/data-structures/heap/max-heap.ts +0 -23
  209. package/src/data-structures/heap/min-heap.ts +0 -25
  210. package/src/data-structures/index.ts +0 -12
  211. package/src/data-structures/linked-list/doubly-linked-list.ts +0 -250
  212. package/src/data-structures/linked-list/index.ts +0 -2
  213. package/src/data-structures/linked-list/singly-linked-list.ts +0 -736
  214. package/src/data-structures/linked-list/skip-linked-list.ts +0 -1
  215. package/src/data-structures/matrix/index.ts +0 -4
  216. package/src/data-structures/matrix/matrix.ts +0 -13
  217. package/src/data-structures/matrix/matrix2d.ts +0 -125
  218. package/src/data-structures/matrix/navigator.ts +0 -87
  219. package/src/data-structures/matrix/vector2d.ts +0 -189
  220. package/src/data-structures/priority-queue/index.ts +0 -3
  221. package/src/data-structures/priority-queue/max-priority-queue.ts +0 -13
  222. package/src/data-structures/priority-queue/min-priority-queue.ts +0 -13
  223. package/src/data-structures/priority-queue/priority-queue.ts +0 -200
  224. package/src/data-structures/queue/deque.ts +0 -139
  225. package/src/data-structures/queue/index.ts +0 -2
  226. package/src/data-structures/queue/queue.ts +0 -122
  227. package/src/data-structures/stack/index.ts +0 -1
  228. package/src/data-structures/stack/stack.ts +0 -103
  229. package/src/data-structures/trampoline.ts +0 -51
  230. package/src/data-structures/trie/index.ts +0 -1
  231. package/src/data-structures/trie/trie.ts +0 -203
  232. package/src/data-structures/types/abstract-graph.ts +0 -51
  233. package/src/data-structures/types/avl-tree.ts +0 -6
  234. package/src/data-structures/types/binary-tree.ts +0 -15
  235. package/src/data-structures/types/bst.ts +0 -5
  236. package/src/data-structures/types/directed-graph.ts +0 -18
  237. package/src/data-structures/types/doubly-linked-list.ts +0 -1
  238. package/src/data-structures/types/heap.ts +0 -8
  239. package/src/data-structures/types/navigator.ts +0 -12
  240. package/src/data-structures/types/priority-queue.ts +0 -9
  241. package/src/data-structures/types/segment-tree.ts +0 -1
  242. package/src/data-structures/types/singly-linked-list.ts +0 -15
  243. package/src/data-structures/types/tree-multiset.ts +0 -3
  244. package/src/data-structures/types/utils.ts +0 -173
  245. package/src/index.ts +0 -1
  246. package/src/utils/index.ts +0 -1
  247. package/src/utils/utils.ts +0 -505
  248. package/tsconfig.json +0 -56
  249. /package/dist/{data-structures/types/abstract-graph.js → interfaces/abstract-binary-tree.js} +0 -0
  250. /package/dist/{data-structures/types/avl-tree.js → interfaces/abstract-graph.js} +0 -0
  251. /package/dist/{data-structures/types/binary-tree.js → interfaces/avl-tree.js} +0 -0
  252. /package/dist/{data-structures/types/bst.js → interfaces/binary-tree.js} +0 -0
  253. /package/dist/{data-structures/types/directed-graph.js → interfaces/bst.js} +0 -0
  254. /package/dist/{data-structures/types/doubly-linked-list.js → interfaces/directed-graph.js} +0 -0
  255. /package/{src/data-structures/hash/pair.ts → dist/interfaces/doubly-linked-list.d.ts} +0 -0
  256. /package/dist/{data-structures/types/heap.js → interfaces/doubly-linked-list.js} +0 -0
  257. /package/{src/data-structures/hash/tree-map.ts → dist/interfaces/heap.d.ts} +0 -0
  258. /package/dist/{data-structures/types/navigator.js → interfaces/heap.js} +0 -0
  259. /package/{src/data-structures/hash/tree-set.ts → dist/interfaces/navigator.d.ts} +0 -0
  260. /package/dist/{data-structures/types/priority-queue.js → interfaces/navigator.js} +0 -0
  261. /package/dist/{data-structures/types/segment-tree.js → interfaces/priority-queue.js} +0 -0
  262. /package/dist/{data-structures/types/singly-linked-list.js → interfaces/rb-tree.js} +0 -0
  263. /package/dist/{data-structures/types/tree-multiset.js → interfaces/segment-tree.js} +0 -0
  264. /package/dist/{data-structures/types → types/data-structures}/segment-tree.d.ts +0 -0
package/package.json CHANGED
@@ -1,54 +1,127 @@
1
1
  {
2
2
  "name": "data-structure-typed",
3
- "version": "0.9.16",
4
- "description": "Hash (CoordinateSet, CoordinateMap) Heap (MaxHeap, MinHeap) Binary Tree (AVL Tree, Binary Indexed Tree, Binary Search Tree, Segment Tree, Tree Multiset) Graph (Directed Graph, Undirected Graph) Linked List (Singly Linked List, Doubly Linked List) Matrix Priority Queue (Max Priority Queue, Min Priority Queue) Queue (Queue, Dequeue) Stack Trie",
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
- "build": "rm -rf dist && npx tsc",
8
- "test": "echo \"Error: no test specified\" && exit 1"
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 Structures",
25
+ "data-structures",
26
+ "algorithm",
27
+ "Binary Search Tree",
28
+ "binary-search-tree",
15
29
  "Binary Tree",
30
+ "binary-tree",
31
+ "BST",
16
32
  "AVL Tree",
17
- "Binary Search Tree (BST)",
33
+ "avl-tree",
34
+ "avl",
18
35
  "Tree Multiset",
19
- "Segment Tree",
20
- "Binary Indexed Tree",
36
+ "tree-multiset",
37
+ "Tree Multiset",
38
+ "dfs",
39
+ "DFS",
40
+ "dfs iterative",
41
+ "DFS Iterative",
42
+ "bfs",
43
+ "BFS",
44
+ "graph",
21
45
  "Graph",
22
46
  "Directed Graph",
47
+ "directed-graph",
23
48
  "Undirected Graph",
24
- "Singly Linked List",
25
- "Hash",
26
- "CoordinateSet",
27
- "CoordinateMap",
49
+ "undirected-graph",
28
50
  "Heap",
29
- "Doubly Linked List",
30
51
  "Priority Queue",
52
+ "priority-queue",
31
53
  "Max Priority Queue",
54
+ "max-priority-queue",
32
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",
33
79
  "Queue",
34
- "ObjectDeque",
35
- "ArrayDeque",
80
+ "Object Deque",
81
+ "Array Deque",
36
82
  "Stack",
37
- "Trie"
83
+ "Hash",
84
+ "morris",
85
+ "Bellman-Ford ",
86
+ "Dijkstra's Algorithm",
87
+ "Floyd-Warshall Algorithm",
88
+ "Tarjan's Algorithm"
38
89
  ],
39
- "author": "Tyler Zeng",
40
- "license": "ISC",
90
+ "author": "Tyler Zeng zrwusa@gmail.com",
91
+ "license": "MIT",
41
92
  "bugs": {
42
93
  "url": "https://github.com/zrwusa/data-structure-typed/issues"
43
94
  },
44
95
  "homepage": "https://github.com/zrwusa/data-structure-typed#readme",
45
- "types": "dist/index.d.ts",
46
96
  "devDependencies": {
47
- "@types/lodash": "^4.14.197",
97
+ "@types/jest": "^29.5.3",
48
98
  "@types/node": "^20.4.9",
49
- "typescript": "^4.6.2"
50
- },
51
- "dependencies": {
52
- "lodash": "^4.17.21"
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"
53
126
  }
54
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-typed.iml" filepath="$PROJECT_DIR$/.idea/data-structure-typed.iml" />
6
- </modules>
7
- </component>
8
- </project>
package/.idea/vcs.xml DELETED
@@ -1,6 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="VcsDirectoryMappings">
4
- <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
- </component>
6
- </project>
@@ -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,5 +0,0 @@
1
- import { AVLTreeNode } from "../binary-tree";
2
- export interface AVLTreeDeleted<T> {
3
- deleted: AVLTreeNode<T> | null;
4
- needBalanced: AVLTreeNode<T> | null;
5
- }
@@ -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,7 +0,0 @@
1
- export interface HeapOptions<T> {
2
- priority?: (element: T) => number;
3
- }
4
- export interface HeapItem<T> {
5
- priority: number;
6
- element: T | null;
7
- }
@@ -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,5 +0,0 @@
1
- import { BSTNode } from "../binary-tree";
2
- export type TreeMultiSetDeletedResult<T> = {
3
- deleted: BSTNode<T> | null;
4
- needBalanced: BSTNode<T> | null;
5
- };
@@ -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;
@@ -1,3 +0,0 @@
1
- export class AaTree {
2
-
3
- }