data-structure-typed 0.9.16 → 1.12.9

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 (199) hide show
  1. package/.dependency-cruiser.js +449 -0
  2. package/.idea/data-structure-typed.iml +2 -0
  3. package/README.md +102 -1
  4. package/dist/data-structures/binary-tree/avl-tree.d.ts +57 -0
  5. package/dist/data-structures/binary-tree/avl-tree.js +57 -0
  6. package/dist/data-structures/binary-tree/binary-indexed-tree.d.ts +27 -0
  7. package/dist/data-structures/binary-tree/binary-indexed-tree.js +27 -0
  8. package/dist/data-structures/binary-tree/binary-tree.d.ts +215 -9
  9. package/dist/data-structures/binary-tree/binary-tree.js +283 -15
  10. package/dist/data-structures/binary-tree/bst.d.ts +16 -0
  11. package/dist/data-structures/binary-tree/bst.js +12 -0
  12. package/dist/data-structures/binary-tree/segment-tree.d.ts +4 -0
  13. package/dist/data-structures/binary-tree/segment-tree.js +4 -0
  14. package/dist/data-structures/binary-tree/tree-multiset.d.ts +4 -0
  15. package/dist/data-structures/binary-tree/tree-multiset.js +4 -0
  16. package/dist/data-structures/graph/abstract-graph.d.ts +163 -13
  17. package/dist/data-structures/graph/abstract-graph.js +166 -12
  18. package/dist/data-structures/graph/directed-graph.d.ts +111 -1
  19. package/dist/data-structures/graph/directed-graph.js +122 -0
  20. package/dist/data-structures/graph/undirected-graph.d.ts +63 -0
  21. package/dist/data-structures/graph/undirected-graph.js +67 -0
  22. package/dist/data-structures/hash/coordinate-map.d.ts +32 -0
  23. package/dist/data-structures/hash/coordinate-map.js +32 -0
  24. package/dist/data-structures/hash/coordinate-set.d.ts +25 -0
  25. package/dist/data-structures/hash/coordinate-set.js +25 -0
  26. package/dist/data-structures/heap/heap.d.ts +26 -31
  27. package/dist/data-structures/heap/heap.js +23 -32
  28. package/dist/data-structures/heap/max-heap.d.ts +6 -1
  29. package/dist/data-structures/heap/max-heap.js +6 -1
  30. package/dist/data-structures/heap/min-heap.d.ts +7 -1
  31. package/dist/data-structures/heap/min-heap.js +7 -1
  32. package/dist/data-structures/index.d.ts +0 -1
  33. package/dist/data-structures/index.js +0 -1
  34. package/dist/data-structures/linked-list/doubly-linked-list.d.ts +14 -6
  35. package/dist/data-structures/linked-list/doubly-linked-list.js +45 -8
  36. package/dist/data-structures/linked-list/singly-linked-list.d.ts +11 -8
  37. package/dist/data-structures/linked-list/singly-linked-list.js +4 -0
  38. package/dist/data-structures/matrix/matrix.d.ts +9 -0
  39. package/dist/data-structures/matrix/matrix.js +11 -0
  40. package/dist/data-structures/matrix/matrix2d.d.ts +82 -2
  41. package/dist/data-structures/matrix/matrix2d.js +82 -2
  42. package/dist/data-structures/matrix/navigator.d.ts +32 -0
  43. package/dist/data-structures/matrix/navigator.js +28 -0
  44. package/dist/data-structures/matrix/vector2d.d.ts +139 -15
  45. package/dist/data-structures/matrix/vector2d.js +139 -15
  46. package/dist/data-structures/priority-queue/max-priority-queue.d.ts +8 -0
  47. package/dist/data-structures/priority-queue/max-priority-queue.js +8 -0
  48. package/dist/data-structures/priority-queue/min-priority-queue.d.ts +8 -0
  49. package/dist/data-structures/priority-queue/min-priority-queue.js +8 -0
  50. package/dist/data-structures/priority-queue/priority-queue.d.ts +130 -0
  51. package/dist/data-structures/priority-queue/priority-queue.js +126 -0
  52. package/dist/data-structures/queue/deque.d.ts +69 -0
  53. package/dist/data-structures/queue/deque.js +69 -0
  54. package/dist/data-structures/queue/queue.d.ts +30 -32
  55. package/dist/data-structures/queue/queue.js +30 -32
  56. package/dist/data-structures/stack/stack.d.ts +26 -31
  57. package/dist/data-structures/stack/stack.js +26 -31
  58. package/dist/data-structures/trie/trie.d.ts +26 -6
  59. package/dist/data-structures/trie/trie.js +26 -7
  60. package/dist/data-structures/types/avl-tree.d.ts +1 -1
  61. package/dist/data-structures/types/binary-tree.d.ts +1 -1
  62. package/dist/data-structures/types/index.d.ts +1 -1
  63. package/dist/data-structures/types/index.js +1 -1
  64. package/dist/data-structures/types/singly-linked-list.d.ts +1 -5
  65. package/dist/data-structures/types/tree-multiset.d.ts +1 -1
  66. package/dist/{data-structures → utils}/trampoline.d.ts +5 -7
  67. package/dist/utils/types/index.d.ts +1 -0
  68. package/dist/utils/types/index.js +17 -0
  69. package/dist/{data-structures → utils}/types/utils.d.ts +8 -0
  70. package/dist/{data-structures → utils}/types/utils.js +1 -0
  71. package/dist/utils/utils.d.ts +1 -1
  72. package/docs/.nojekyll +1 -0
  73. package/docs/assets/highlight.css +85 -0
  74. package/docs/assets/main.js +58 -0
  75. package/docs/assets/search.js +1 -0
  76. package/docs/assets/style.css +1367 -0
  77. package/docs/classes/AVLTree.html +2046 -0
  78. package/docs/classes/AVLTreeNode.html +423 -0
  79. package/docs/classes/AaTree.html +117 -0
  80. package/docs/classes/AbstractEdge.html +198 -0
  81. package/docs/classes/AbstractGraph.html +891 -0
  82. package/docs/classes/AbstractVertex.html +164 -0
  83. package/docs/classes/ArrayDeque.html +384 -0
  84. package/docs/classes/BST.html +1893 -0
  85. package/docs/classes/BSTNode.html +425 -0
  86. package/docs/classes/BTree.html +117 -0
  87. package/docs/classes/BinaryIndexedTree.html +244 -0
  88. package/docs/classes/BinaryTree.html +1754 -0
  89. package/docs/classes/BinaryTreeNode.html +396 -0
  90. package/docs/classes/Character.html +165 -0
  91. package/docs/classes/CoordinateMap.html +394 -0
  92. package/docs/classes/CoordinateSet.html +355 -0
  93. package/docs/classes/Deque.html +617 -0
  94. package/docs/classes/DirectedEdge.html +247 -0
  95. package/docs/classes/DirectedGraph.html +1207 -0
  96. package/docs/classes/DirectedVertex.html +154 -0
  97. package/docs/classes/DoublyLinkedList.html +619 -0
  98. package/docs/classes/DoublyLinkedListNode.html +160 -0
  99. package/docs/classes/Heap.html +315 -0
  100. package/docs/classes/Matrix2D.html +447 -0
  101. package/docs/classes/MatrixNTI2D.html +181 -0
  102. package/docs/classes/MaxHeap.html +325 -0
  103. package/docs/classes/MaxPriorityQueue.html +668 -0
  104. package/docs/classes/MinHeap.html +326 -0
  105. package/docs/classes/MinPriorityQueue.html +668 -0
  106. package/docs/classes/Navigator.html +285 -0
  107. package/docs/classes/ObjectDeque.html +289 -0
  108. package/docs/classes/PriorityQueue.html +643 -0
  109. package/docs/classes/Queue.html +337 -0
  110. package/docs/classes/RBTree.html +117 -0
  111. package/docs/classes/SegmentTree.html +234 -0
  112. package/docs/classes/SegmentTreeNode.html +302 -0
  113. package/docs/classes/SinglyLinkedList.html +1035 -0
  114. package/docs/classes/SinglyLinkedListNode.html +304 -0
  115. package/docs/classes/SplayTree.html +117 -0
  116. package/docs/classes/Stack.html +313 -0
  117. package/docs/classes/TreeMultiSet.html +1897 -0
  118. package/docs/classes/Trie.html +317 -0
  119. package/docs/classes/TrieNode.html +221 -0
  120. package/docs/classes/TwoThreeTree.html +117 -0
  121. package/docs/classes/UndirectedEdge.html +220 -0
  122. package/docs/classes/UndirectedGraph.html +1006 -0
  123. package/docs/classes/UndirectedVertex.html +154 -0
  124. package/docs/classes/Vector2D.html +746 -0
  125. package/docs/enums/CP.html +126 -0
  126. package/docs/enums/FamilyPosition.html +126 -0
  127. package/docs/enums/LoopType.html +119 -0
  128. package/docs/index.html +288 -0
  129. package/docs/modules.html +146 -0
  130. package/jest.config.js +5 -0
  131. package/package.json +19 -11
  132. package/rename_clear_files.sh +29 -0
  133. package/src/assets/complexities-diff.jpg +0 -0
  134. package/src/assets/data-structure-complexities.jpg +0 -0
  135. package/src/data-structures/binary-tree/avl-tree.ts +57 -0
  136. package/src/data-structures/binary-tree/binary-indexed-tree.ts +27 -0
  137. package/src/data-structures/binary-tree/binary-tree.ts +288 -18
  138. package/src/data-structures/binary-tree/bst.ts +16 -1
  139. package/src/data-structures/binary-tree/segment-tree.ts +5 -0
  140. package/src/data-structures/binary-tree/tree-multiset.ts +4 -0
  141. package/src/data-structures/diagrams/README.md +5 -7
  142. package/src/data-structures/graph/abstract-graph.ts +167 -15
  143. package/src/data-structures/graph/diagrams/adjacency-list-pros-cons.jpg +0 -0
  144. package/src/data-structures/graph/diagrams/adjacency-list.jpg +0 -0
  145. package/src/data-structures/graph/diagrams/adjacency-matrix-pros-cons.jpg +0 -0
  146. package/src/data-structures/graph/diagrams/adjacency-matrix.jpg +0 -0
  147. package/src/data-structures/graph/diagrams/dfs-can-do.jpg +0 -0
  148. package/src/data-structures/graph/diagrams/edge-list-pros-cons.jpg +0 -0
  149. package/src/data-structures/graph/diagrams/edge-list.jpg +0 -0
  150. package/src/data-structures/graph/diagrams/max-flow.jpg +0 -0
  151. package/src/data-structures/graph/diagrams/mst.jpg +0 -0
  152. package/src/data-structures/graph/diagrams/tarjan.webp +0 -0
  153. package/src/data-structures/graph/directed-graph.ts +127 -5
  154. package/src/data-structures/graph/undirected-graph.ts +67 -1
  155. package/src/data-structures/hash/coordinate-map.ts +32 -0
  156. package/src/data-structures/hash/coordinate-set.ts +25 -0
  157. package/src/data-structures/heap/heap.ts +27 -32
  158. package/src/data-structures/heap/max-heap.ts +6 -1
  159. package/src/data-structures/heap/min-heap.ts +7 -1
  160. package/src/data-structures/index.ts +0 -1
  161. package/src/data-structures/linked-list/doubly-linked-list.ts +49 -8
  162. package/src/data-structures/linked-list/singly-linked-list.ts +39 -8
  163. package/src/data-structures/matrix/matrix.ts +11 -0
  164. package/src/data-structures/matrix/matrix2d.ts +82 -2
  165. package/src/data-structures/matrix/navigator.ts +32 -0
  166. package/src/data-structures/matrix/vector2d.ts +139 -15
  167. package/src/data-structures/priority-queue/max-priority-queue.ts +8 -0
  168. package/src/data-structures/priority-queue/min-priority-queue.ts +8 -0
  169. package/src/data-structures/priority-queue/priority-queue.ts +130 -0
  170. package/src/data-structures/queue/deque.ts +69 -0
  171. package/src/data-structures/queue/queue.ts +30 -32
  172. package/src/data-structures/stack/stack.ts +26 -31
  173. package/src/data-structures/trie/trie.ts +26 -7
  174. package/src/data-structures/types/avl-tree.ts +1 -1
  175. package/src/data-structures/types/binary-tree.ts +1 -1
  176. package/src/data-structures/types/bst.ts +1 -1
  177. package/src/data-structures/types/index.ts +1 -1
  178. package/src/data-structures/types/navigator.ts +1 -0
  179. package/src/data-structures/types/singly-linked-list.ts +1 -15
  180. package/src/data-structures/types/tree-multiset.ts +1 -1
  181. package/src/{data-structures → utils}/trampoline.ts +6 -6
  182. package/src/utils/types/index.ts +1 -0
  183. package/src/{data-structures → utils}/types/utils.ts +7 -0
  184. package/src/utils/utils.ts +12 -2
  185. package/tests/unit/data-structures/binary-tree/bst.test.ts +185 -0
  186. package/tests/unit/data-structures/graph/abstract-graph.ts +0 -0
  187. package/tests/unit/data-structures/graph/directed-graph.test.ts +71 -0
  188. package/tests/unit/data-structures/graph/index.ts +3 -0
  189. package/tests/unit/data-structures/graph/undirected-graph.ts +0 -0
  190. package/src/data-structures/graph/diagrams/adjacency-list-pros-cons.png +0 -0
  191. package/src/data-structures/graph/diagrams/adjacency-list.png +0 -0
  192. package/src/data-structures/graph/diagrams/adjacency-matrix-pros-cons.png +0 -0
  193. package/src/data-structures/graph/diagrams/adjacency-matrix.png +0 -0
  194. package/src/data-structures/graph/diagrams/dfs-can-do.png +0 -0
  195. package/src/data-structures/graph/diagrams/edge-list-pros-cons.png +0 -0
  196. package/src/data-structures/graph/diagrams/edge-list.png +0 -0
  197. package/src/data-structures/graph/diagrams/max-flow.png +0 -0
  198. package/src/data-structures/graph/diagrams/mst.png +0 -0
  199. /package/dist/{data-structures → utils}/trampoline.js +0 -0
@@ -0,0 +1,449 @@
1
+ /** @type {import('dependency-cruiser').IConfiguration} */
2
+ module.exports = {
3
+ forbidden: [
4
+ /* rules from the 'recommended' preset: */
5
+ {
6
+ name: 'no-circular',
7
+ severity: 'warn',
8
+ comment:
9
+ 'This dependency is part of a circular relationship. You might want to revise ' +
10
+ 'your solution (i.e. use dependency inversion, make sure the modules have a single responsibility) ',
11
+ from: {},
12
+ to: {
13
+ circular: true
14
+ }
15
+ },
16
+ {
17
+ name: 'no-orphans',
18
+ comment:
19
+ "This is an orphan module - it's likely not used (anymore?). Either use it or " +
20
+ "remove it. If it's logical this module is an orphan (i.e. it's a config file), " +
21
+ "add an exception for it in your dependency-cruiser configuration. By default " +
22
+ "this rule does not scrutinize dot-files (e.g. .eslintrc.js), TypeScript declaration " +
23
+ "files (.d.ts), tsconfig.json and some of the babel and webpack configs.",
24
+ severity: 'warn',
25
+ from: {
26
+ orphan: true,
27
+ pathNot: [
28
+ '(^|/)\\.[^/]+\\.(js|cjs|mjs|ts|json)$', // dot files
29
+ '\\.d\\.ts$', // TypeScript declaration files
30
+ '(^|/)tsconfig\\.json$', // TypeScript config
31
+ '(^|/)(babel|webpack)\\.config\\.(js|cjs|mjs|ts|json)$' // other configs
32
+ ]
33
+ },
34
+ to: {},
35
+ },
36
+ {
37
+ name: 'no-deprecated-core',
38
+ comment:
39
+ 'A module depends on a node core module that has been deprecated. Find an alternative - these are ' +
40
+ "bound to exist - node doesn't deprecate lightly.",
41
+ severity: 'warn',
42
+ from: {},
43
+ to: {
44
+ dependencyTypes: [
45
+ 'core'
46
+ ],
47
+ path: [
48
+ '^(v8\/tools\/codemap)$',
49
+ '^(v8\/tools\/consarray)$',
50
+ '^(v8\/tools\/csvparser)$',
51
+ '^(v8\/tools\/logreader)$',
52
+ '^(v8\/tools\/profile_view)$',
53
+ '^(v8\/tools\/profile)$',
54
+ '^(v8\/tools\/SourceMap)$',
55
+ '^(v8\/tools\/splaytree)$',
56
+ '^(v8\/tools\/tickprocessor-driver)$',
57
+ '^(v8\/tools\/tickprocessor)$',
58
+ '^(node-inspect\/lib\/_inspect)$',
59
+ '^(node-inspect\/lib\/internal\/inspect_client)$',
60
+ '^(node-inspect\/lib\/internal\/inspect_repl)$',
61
+ '^(async_hooks)$',
62
+ '^(punycode)$',
63
+ '^(domain)$',
64
+ '^(constants)$',
65
+ '^(sys)$',
66
+ '^(_linklist)$',
67
+ '^(_stream_wrap)$'
68
+ ],
69
+ }
70
+ },
71
+ {
72
+ name: 'not-to-deprecated',
73
+ comment:
74
+ 'This module uses a (version of an) npm module that has been deprecated. Either upgrade to a later ' +
75
+ 'version of that module, or find an alternative. Deprecated modules are a security risk.',
76
+ severity: 'warn',
77
+ from: {},
78
+ to: {
79
+ dependencyTypes: [
80
+ 'deprecated'
81
+ ]
82
+ }
83
+ },
84
+ {
85
+ name: 'no-non-package-json',
86
+ severity: 'error',
87
+ comment:
88
+ "This module depends on an npm package that isn't in the 'dependencies' section of your package.json. " +
89
+ "That's problematic as the package either (1) won't be available on live (2 - worse) will be " +
90
+ "available on live with an non-guaranteed version. Fix it by adding the package to the dependencies " +
91
+ "in your package.json.",
92
+ from: {},
93
+ to: {
94
+ dependencyTypes: [
95
+ 'npm-no-pkg',
96
+ 'npm-unknown'
97
+ ]
98
+ }
99
+ },
100
+ {
101
+ name: 'not-to-unresolvable',
102
+ comment:
103
+ "This module depends on a module that cannot be found ('resolved to disk'). If it's an npm " +
104
+ 'module: add it to your package.json. In all other cases you likely already know what to do.',
105
+ severity: 'error',
106
+ from: {},
107
+ to: {
108
+ couldNotResolve: true
109
+ }
110
+ },
111
+ {
112
+ name: 'no-duplicate-dep-types',
113
+ comment:
114
+ "Likely this module depends on an external ('npm') package that occurs more than once " +
115
+ "in your package.json i.e. bot as a devDependencies and in dependencies. This will cause " +
116
+ "maintenance problems later on.",
117
+ severity: 'warn',
118
+ from: {},
119
+ to: {
120
+ moreThanOneDependencyType: true,
121
+ // as it's pretty common to have a type import be a type only import
122
+ // _and_ (e.g.) a devDependency - don't consider type-only dependency
123
+ // types for this rule
124
+ dependencyTypesNot: ["type-only"]
125
+ }
126
+ },
127
+
128
+ /* rules you might want to tweak for your specific situation: */
129
+ {
130
+ name: 'not-to-spec',
131
+ comment:
132
+ 'This module depends on a spec (test) file. The sole responsibility of a spec file is to test code. ' +
133
+ "If there's something in a spec that's of use to other modules, it doesn't have that single " +
134
+ 'responsibility anymore. Factor it out into (e.g.) a separate utility/ helper or a mock.',
135
+ severity: 'error',
136
+ from: {},
137
+ to: {
138
+ path: '\\.(spec|test)\\.(js|mjs|cjs|ts|ls|coffee|litcoffee|coffee\\.md)$'
139
+ }
140
+ },
141
+ {
142
+ name: 'not-to-dev-dep',
143
+ severity: 'error',
144
+ comment:
145
+ "This module depends on an npm package from the 'devDependencies' section of your " +
146
+ 'package.json. It looks like something that ships to production, though. To prevent problems ' +
147
+ "with npm packages that aren't there on production declare it (only!) in the 'dependencies'" +
148
+ 'section of your package.json. If this module is development only - add it to the ' +
149
+ 'from.pathNot re of the not-to-dev-dep rule in the dependency-cruiser configuration',
150
+ from: {
151
+ path: '^(src)',
152
+ pathNot: '\\.(spec|test)\\.(js|mjs|cjs|ts|ls|coffee|litcoffee|coffee\\.md)$'
153
+ },
154
+ to: {
155
+ dependencyTypes: [
156
+ 'npm-dev'
157
+ ]
158
+ }
159
+ },
160
+ {
161
+ name: 'optional-deps-used',
162
+ severity: 'info',
163
+ comment:
164
+ "This module depends on an npm package that is declared as an optional dependency " +
165
+ "in your package.json. As this makes sense in limited situations only, it's flagged here. " +
166
+ "If you're using an optional dependency here by design - add an exception to your" +
167
+ "dependency-cruiser configuration.",
168
+ from: {},
169
+ to: {
170
+ dependencyTypes: [
171
+ 'npm-optional'
172
+ ]
173
+ }
174
+ },
175
+ {
176
+ name: 'peer-deps-used',
177
+ comment:
178
+ "This module depends on an npm package that is declared as a peer dependency " +
179
+ "in your package.json. This makes sense if your package is e.g. a plugin, but in " +
180
+ "other cases - maybe not so much. If the use of a peer dependency is intentional " +
181
+ "add an exception to your dependency-cruiser configuration.",
182
+ severity: 'warn',
183
+ from: {},
184
+ to: {
185
+ dependencyTypes: [
186
+ 'npm-peer'
187
+ ]
188
+ }
189
+ }
190
+ ],
191
+ options: {
192
+
193
+ /* conditions specifying which files not to follow further when encountered:
194
+ - path: a regular expression to match
195
+ - dependencyTypes: see https://github.com/sverweij/dependency-cruiser/blob/main/doc/rules-reference.md#dependencytypes-and-dependencytypesnot
196
+ for a complete list
197
+ */
198
+ doNotFollow: {
199
+ path: ['node_modules', 'src/libs']
200
+ },
201
+
202
+ /* conditions specifying which dependencies to exclude
203
+ - path: a regular expression to match
204
+ - dynamic: a boolean indicating whether to ignore dynamic (true) or static (false) dependencies.
205
+ leave out if you want to exclude neither (recommended!)
206
+ */
207
+ // exclude : {
208
+ // path: '',
209
+ // dynamic: true
210
+ // },
211
+
212
+ /* pattern specifying which files to include (regular expression)
213
+ dependency-cruiser will skip everything not matching this pattern
214
+ */
215
+ // includeOnly : '',
216
+
217
+ /* dependency-cruiser will include modules matching against the focus
218
+ regular expression in its output, as well as their neighbours (direct
219
+ dependencies and dependents)
220
+ */
221
+ // focus : '',
222
+
223
+ /* list of module systems to cruise */
224
+ // moduleSystems: ['amd', 'cjs', 'es6', 'tsd'],
225
+
226
+ /* prefix for links in html and svg output (e.g. 'https://github.com/you/yourrepo/blob/develop/'
227
+ to open it on your online repo or `vscode://file/${process.cwd()}/` to
228
+ open it in visual studio code),
229
+ */
230
+ // prefix: '',
231
+
232
+ /* false (the default): ignore dependencies that only exist before typescript-to-javascript compilation
233
+ true: also detect dependencies that only exist before typescript-to-javascript compilation
234
+ "specify": for each dependency identify whether it only exists before compilation or also after
235
+ */
236
+ tsPreCompilationDeps: true,
237
+
238
+ /*
239
+ list of extensions to scan that aren't javascript or compile-to-javascript.
240
+ Empty by default. Only put extensions in here that you want to take into
241
+ account that are _not_ parsable.
242
+ */
243
+ // extraExtensionsToScan: [".json", ".jpg", ".png", ".svg", ".webp"],
244
+
245
+ /* if true combines the package.jsons found from the module up to the base
246
+ folder the cruise is initiated from. Useful for how (some) mono-repos
247
+ manage dependencies & dependency definitions.
248
+ */
249
+ // combinedDependencies: false,
250
+
251
+ /* if true leave symlinks untouched, otherwise use the realpath */
252
+ // preserveSymlinks: false,
253
+
254
+ /* TypeScript project file ('tsconfig.json') to use for
255
+ (1) compilation and
256
+ (2) resolution (e.g. with the paths property)
257
+
258
+ The (optional) fileName attribute specifies which file to take (relative to
259
+ dependency-cruiser's current working directory). When not provided
260
+ defaults to './tsconfig.json'.
261
+ */
262
+ tsConfig: {
263
+ fileName: 'tsconfig.json'
264
+ },
265
+
266
+ /* Webpack configuration to use to get resolve options from.
267
+
268
+ The (optional) fileName attribute specifies which file to take (relative
269
+ to dependency-cruiser's current working directory. When not provided defaults
270
+ to './webpack.conf.js'.
271
+
272
+ The (optional) `env` and `arguments` attributes contain the parameters to be passed if
273
+ your webpack config is a function and takes them (see webpack documentation
274
+ for details)
275
+ */
276
+ // webpackConfig: {
277
+ // fileName: './webpack.config.js',
278
+ // env: {},
279
+ // arguments: {},
280
+ // },
281
+
282
+ /* Babel config ('.babelrc', '.babelrc.json', '.babelrc.json5', ...) to use
283
+ for compilation (and whatever other naughty things babel plugins do to
284
+ source code). This feature is well tested and usable, but might change
285
+ behavior a bit over time (e.g. more precise results for used module
286
+ systems) without dependency-cruiser getting a major version bump.
287
+ */
288
+ // babelConfig: {
289
+ // fileName: './.babelrc'
290
+ // },
291
+
292
+ /* List of strings you have in use in addition to cjs/ es6 requires
293
+ & imports to declare module dependencies. Use this e.g. if you've
294
+ re-declared require, use a require-wrapper or use window.require as
295
+ a hack.
296
+ */
297
+ // exoticRequireStrings: [],
298
+ /* options to pass on to enhanced-resolve, the package dependency-cruiser
299
+ uses to resolve module references to disk. You can set most of these
300
+ options in a webpack.conf.js - this section is here for those
301
+ projects that don't have a separate webpack config file.
302
+
303
+ Note: settings in webpack.conf.js override the ones specified here.
304
+ */
305
+ enhancedResolveOptions: {
306
+ /* List of strings to consider as 'exports' fields in package.json. Use
307
+ ['exports'] when you use packages that use such a field and your environment
308
+ supports it (e.g. node ^12.19 || >=14.7 or recent versions of webpack).
309
+
310
+ If you have an `exportsFields` attribute in your webpack config, that one
311
+ will have precedence over the one specified here.
312
+ */
313
+ exportsFields: ["exports"],
314
+ /* List of conditions to check for in the exports field. e.g. use ['imports']
315
+ if you're only interested in exposed es6 modules, ['require'] for commonjs,
316
+ or all conditions at once `(['import', 'require', 'node', 'default']`)
317
+ if anything goes for you. Only works when the 'exportsFields' array is
318
+ non-empty.
319
+
320
+ If you have a 'conditionNames' attribute in your webpack config, that one will
321
+ have precedence over the one specified here.
322
+ */
323
+ conditionNames: ["import", "require", "node", "default"],
324
+ /*
325
+ The extensions, by default are the same as the ones dependency-cruiser
326
+ can access (run `npx depcruise --info` to see which ones that are in
327
+ _your_ environment. If that list is larger than what you need (e.g.
328
+ it contains .js, .jsx, .ts, .tsx, .cts, .mts - but you don't use
329
+ TypeScript you can pass just the extensions you actually use (e.g.
330
+ [".js", ".jsx"]). This can speed up the most expensive step in
331
+ dependency cruising (module resolution) quite a bit.
332
+ */
333
+ // extensions: [".js", ".jsx", ".ts", ".tsx", ".d.ts"],
334
+ /*
335
+ If your TypeScript project makes use of types specified in 'types'
336
+ fields in package.jsons of external dependencies, specify "types"
337
+ in addition to "main" in here, so enhanced-resolve (the resolver
338
+ dependency-cruiser uses) knows to also look there. You can also do
339
+ this if you're not sure, but still use TypeScript. In a future version
340
+ of dependency-cruiser this will likely become the default.
341
+ */
342
+ mainFields: ["main", "types"],
343
+ },
344
+ reporterOptions: {
345
+ dot: {
346
+ /* pattern of modules that can be consolidated in the detailed
347
+ graphical dependency graph. The default pattern in this configuration
348
+ collapses everything in node_modules to one folder deep so you see
349
+ the external modules, but not the innards your app depends upon.
350
+ */
351
+ collapsePattern: 'node_modules/(@[^/]+/[^/]+|[^/]+)',
352
+
353
+ /* Options to tweak the appearance of your graph.See
354
+ https://github.com/sverweij/dependency-cruiser/blob/main/doc/options-reference.md#reporteroptions
355
+ for details and some examples. If you don't specify a theme
356
+ don't worry - dependency-cruiser will fall back to the default one.
357
+ */
358
+ // theme: {
359
+ // graph: {
360
+ // /* use splines: "ortho" for straight lines. Be aware though
361
+ // graphviz might take a long time calculating ortho(gonal)
362
+ // routings.
363
+ // */
364
+ // splines: "true"
365
+ // },
366
+ // modules: [
367
+ // {
368
+ // criteria: { matchesFocus: true },
369
+ // attributes: {
370
+ // fillcolor: "lime",
371
+ // penwidth: 2,
372
+ // },
373
+ // },
374
+ // {
375
+ // criteria: { matchesFocus: false },
376
+ // attributes: {
377
+ // fillcolor: "lightgrey",
378
+ // },
379
+ // },
380
+ // {
381
+ // criteria: { matchesReaches: true },
382
+ // attributes: {
383
+ // fillcolor: "lime",
384
+ // penwidth: 2,
385
+ // },
386
+ // },
387
+ // {
388
+ // criteria: { matchesReaches: false },
389
+ // attributes: {
390
+ // fillcolor: "lightgrey",
391
+ // },
392
+ // },
393
+ // {
394
+ // criteria: { source: "^src/model" },
395
+ // attributes: { fillcolor: "#ccccff" }
396
+ // },
397
+ // {
398
+ // criteria: { source: "^src/view" },
399
+ // attributes: { fillcolor: "#ccffcc" }
400
+ // },
401
+ // ],
402
+ // dependencies: [
403
+ // {
404
+ // criteria: { "rules[0].severity": "error" },
405
+ // attributes: { fontcolor: "red", color: "red" }
406
+ // },
407
+ // {
408
+ // criteria: { "rules[0].severity": "warn" },
409
+ // attributes: { fontcolor: "orange", color: "orange" }
410
+ // },
411
+ // {
412
+ // criteria: { "rules[0].severity": "info" },
413
+ // attributes: { fontcolor: "blue", color: "blue" }
414
+ // },
415
+ // {
416
+ // criteria: { resolved: "^src/model" },
417
+ // attributes: { color: "#0000ff77" }
418
+ // },
419
+ // {
420
+ // criteria: { resolved: "^src/view" },
421
+ // attributes: { color: "#00770077" }
422
+ // }
423
+ // ]
424
+ // }
425
+ },
426
+ archi: {
427
+ /* pattern of modules that can be consolidated in the high level
428
+ graphical dependency graph. If you use the high level graphical
429
+ dependency graph reporter (`archi`) you probably want to tweak
430
+ this collapsePattern to your situation.
431
+ */
432
+ collapsePattern: '^(packages|src|lib|app|bin|test(s?)|spec(s?))/[^/]+|node_modules/(@[^/]+/[^/]+|[^/]+)',
433
+
434
+ /* Options to tweak the appearance of your graph.See
435
+ https://github.com/sverweij/dependency-cruiser/blob/main/doc/options-reference.md#reporteroptions
436
+ for details and some examples. If you don't specify a theme
437
+ for 'archi' dependency-cruiser will use the one specified in the
438
+ dot section (see above), if any, and otherwise use the default one.
439
+ */
440
+ // theme: {
441
+ // },
442
+ },
443
+ "text": {
444
+ "highlightFocused": true
445
+ },
446
+ }
447
+ }
448
+ };
449
+ // generated: dependency-cruiser@13.1.1 on 2023-08-02T09:11:55.676Z
@@ -5,6 +5,8 @@
5
5
  <excludeFolder url="file://$MODULE_DIR$/temp" />
6
6
  <excludeFolder url="file://$MODULE_DIR$/.tmp" />
7
7
  <excludeFolder url="file://$MODULE_DIR$/tmp" />
8
+ <excludeFolder url="file://$MODULE_DIR$/dist" />
9
+ <excludeFolder url="file://$MODULE_DIR$/notes" />
8
10
  </content>
9
11
  <orderEntry type="inheritedJdk" />
10
12
  <orderEntry type="sourceFolder" forTests="false" />
package/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # data-structure-typed
2
2
 
3
+ Javascript Data Structure, TypeScript Data Structure Library
4
+
3
5
  ## install
4
6
 
5
7
  ### yarn
@@ -14,8 +16,71 @@ yarn add data-structure-typed
14
16
  npm install data-structure-typed
15
17
  ```
16
18
 
19
+ ## api docs
20
+
21
+ [//]: # ([api docs]&#40;https://data-structure-typed-docs.vercel.app/&#41;)
22
+
23
+ <nav class="tsd-navigation"><a href="https://data-structure-typed-docs.vercel.app/modules.html" class="current"><span>data-<wbr/>structure-<wbr/>typed</span></a>
24
+ <ul class="tsd-small-nested-navigation">
25
+
26
+ [//]: # (<li><a href="https://data-structure-typed-docs.vercel.app/enums/CP.html"><span>CP</span></a></li>)
27
+
28
+ [//]: # (<li><a href="https://data-structure-typed-docs.vercel.app/enums/FamilyPosition.html"><span>Family<wbr/>Position</span></a></li>)
29
+
30
+ [//]: # (<li><a href="https://data-structure-typed-docs.vercel.app/enums/LoopType.html"><span>Loop<wbr/>Type</span></a></li>)
31
+ <li><a href="https://data-structure-typed-docs.vercel.app/classes/AVLTree.html"><span>AVLTree</span></a></li>
32
+ <li><a href="https://data-structure-typed-docs.vercel.app/classes/AVLTreeNode.html"><span>AVLTree<wbr/>Node</span></a></li>
33
+ <li><a href="https://data-structure-typed-docs.vercel.app/classes/AaTree.html"><span>Aa<wbr/>Tree</span></a></li>
34
+ <li><a href="https://data-structure-typed-docs.vercel.app/classes/AbstractEdge.html"><span>Abstract<wbr/>Edge</span></a></li>
35
+ <li><a href="https://data-structure-typed-docs.vercel.app/classes/AbstractGraph.html"><span>Abstract<wbr/>Graph</span></a></li>
36
+ <li><a href="https://data-structure-typed-docs.vercel.app/classes/AbstractVertex.html"><span>Abstract<wbr/>Vertex</span></a></li>
37
+ <li><a href="https://data-structure-typed-docs.vercel.app/classes/ArrayDeque.html"><span>Array<wbr/>Deque</span></a></li>
38
+ <li><a href="https://data-structure-typed-docs.vercel.app/classes/BST.html"><span>BST</span></a></li>
39
+ <li><a href="https://data-structure-typed-docs.vercel.app/classes/BSTNode.html"><span>BSTNode</span></a></li>
40
+ <li><a href="https://data-structure-typed-docs.vercel.app/classes/BTree.html"><span>BTree</span></a></li>
41
+ <li><a href="https://data-structure-typed-docs.vercel.app/classes/BinaryIndexedTree.html"><span>Binary<wbr/>Indexed<wbr/>Tree</span></a></li>
42
+ <li><a href="https://data-structure-typed-docs.vercel.app/classes/BinaryTree.html"><span>Binary<wbr/>Tree</span></a></li>
43
+ <li><a href="https://data-structure-typed-docs.vercel.app/classes/BinaryTreeNode.html"><span>Binary<wbr/>Tree<wbr/>Node</span></a></li>
44
+ <li><a href="https://data-structure-typed-docs.vercel.app/classes/Character.html"><span>Character</span></a></li>
45
+ <li><a href="https://data-structure-typed-docs.vercel.app/classes/CoordinateMap.html"><span>Coordinate<wbr/>Map</span></a></li>
46
+ <li><a href="https://data-structure-typed-docs.vercel.app/classes/CoordinateSet.html"><span>Coordinate<wbr/>Set</span></a></li>
47
+ <li><a href="https://data-structure-typed-docs.vercel.app/classes/Deque.html"><span>Deque</span></a></li>
48
+ <li><a href="https://data-structure-typed-docs.vercel.app/classes/DirectedEdge.html"><span>Directed<wbr/>Edge</span></a></li>
49
+ <li><a href="https://data-structure-typed-docs.vercel.app/classes/DirectedGraph.html"><span>Directed<wbr/>Graph</span></a></li>
50
+ <li><a href="https://data-structure-typed-docs.vercel.app/classes/DirectedVertex.html"><span>Directed<wbr/>Vertex</span></a></li>
51
+ <li><a href="https://data-structure-typed-docs.vercel.app/classes/DoublyLinkedList.html"><span>Doubly<wbr/>Linked<wbr/>List</span></a></li>
52
+ <li><a href="https://data-structure-typed-docs.vercel.app/classes/DoublyLinkedListNode.html"><span>Doubly<wbr/>Linked<wbr/>List<wbr/>Node</span></a></li>
53
+ <li><a href="https://data-structure-typed-docs.vercel.app/classes/Heap.html"><span>Heap</span></a></li>
54
+ <li><a href="https://data-structure-typed-docs.vercel.app/classes/Matrix2D.html"><span>Matrix2D</span></a></li>
55
+ <li><a href="https://data-structure-typed-docs.vercel.app/classes/MatrixNTI2D.html"><span>MatrixNTI2D</span></a></li>
56
+ <li><a href="https://data-structure-typed-docs.vercel.app/classes/MaxHeap.html"><span>Max<wbr/>Heap</span></a></li>
57
+ <li><a href="https://data-structure-typed-docs.vercel.app/classes/MaxPriorityQueue.html"><span>Max<wbr/>Priority<wbr/>Queue</span></a></li>
58
+ <li><a href="https://data-structure-typed-docs.vercel.app/classes/MinHeap.html"><span>Min<wbr/>Heap</span></a></li>
59
+ <li><a href="https://data-structure-typed-docs.vercel.app/classes/MinPriorityQueue.html"><span>Min<wbr/>Priority<wbr/>Queue</span></a></li>
60
+ <li><a href="https://data-structure-typed-docs.vercel.app/classes/Navigator.html"><span>Navigator</span></a></li>
61
+ <li><a href="https://data-structure-typed-docs.vercel.app/classes/ObjectDeque.html"><span>Object<wbr/>Deque</span></a></li>
62
+ <li><a href="https://data-structure-typed-docs.vercel.app/classes/PriorityQueue.html"><span>Priority<wbr/>Queue</span></a></li>
63
+ <li><a href="https://data-structure-typed-docs.vercel.app/classes/Queue.html"><span>Queue</span></a></li>
64
+ <li><a href="https://data-structure-typed-docs.vercel.app/classes/RBTree.html"><span>RBTree</span></a></li>
65
+ <li><a href="https://data-structure-typed-docs.vercel.app/classes/SegmentTree.html"><span>Segment<wbr/>Tree</span></a></li>
66
+ <li><a href="https://data-structure-typed-docs.vercel.app/classes/SegmentTreeNode.html"><span>Segment<wbr/>Tree<wbr/>Node</span></a></li>
67
+ <li><a href="https://data-structure-typed-docs.vercel.app/classes/SinglyLinkedList.html"><span>Singly<wbr/>Linked<wbr/>List</span></a></li>
68
+ <li><a href="https://data-structure-typed-docs.vercel.app/classes/SinglyLinkedListNode.html"><span>Singly<wbr/>Linked<wbr/>List<wbr/>Node</span></a></li>
69
+ <li><a href="https://data-structure-typed-docs.vercel.app/classes/SplayTree.html"><span>Splay<wbr/>Tree</span></a></li>
70
+ <li><a href="https://data-structure-typed-docs.vercel.app/classes/Stack.html"><span>Stack</span></a></li>
71
+ <li><a href="https://data-structure-typed-docs.vercel.app/classes/TreeMultiSet.html"><span>Tree<wbr/>Multi<wbr/>Set</span></a></li>
72
+ <li><a href="https://data-structure-typed-docs.vercel.app/classes/Trie.html"><span>Trie</span></a></li>
73
+ <li><a href="https://data-structure-typed-docs.vercel.app/classes/TrieNode.html"><span>Trie<wbr/>Node</span></a></li>
74
+ <li><a href="https://data-structure-typed-docs.vercel.app/classes/TwoThreeTree.html"><span>Two<wbr/>Three<wbr/>Tree</span></a></li>
75
+ <li><a href="https://data-structure-typed-docs.vercel.app/classes/UndirectedEdge.html"><span>Undirected<wbr/>Edge</span></a></li>
76
+ <li><a href="https://data-structure-typed-docs.vercel.app/classes/UndirectedGraph.html"><span>Undirected<wbr/>Graph</span></a></li>
77
+ <li><a href="https://data-structure-typed-docs.vercel.app/classes/UndirectedVertex.html"><span>Undirected<wbr/>Vertex</span></a></li>
78
+ <li><a href="https://data-structure-typed-docs.vercel.app/classes/Vector2D.html"><span>Vector2D</span></a></li></ul></nav>
79
+
17
80
  ## data structures
18
81
 
82
+ Meticulously crafted to empower developers with a versatile set of essential data structures. Our library includes a wide range of data structures:
83
+ Binary Tree, Binary Search Tree (BST), AVL Tree, Tree Multiset, Segment Tree, Binary Indexed Tree, Graph, Directed Graph, Undirected Graph, Linked List, Singly Linked List, Doubly Linked List, Queue, Object Deque, Array Deque, Stack, Hash, Coordinate Set, Coordinate Map, Heap, Priority Queue, Max Priority Queue, Min Priority Queue, Trie
19
84
  <table>
20
85
  <thead>
21
86
  <tr>
@@ -194,4 +259,40 @@ npm install data-structure-typed
194
259
 
195
260
  ![complexities](src/assets/complexities-diff.jpg)
196
261
 
197
- ![complexities of data structures](src/assets/data-structure-complexities.jpg)
262
+ ![complexities of data structures](src/assets/data-structure-complexities.jpg)
263
+
264
+ ![](src/data-structures/binary-tree/diagrams/bst-rotation.gif)
265
+
266
+ ![](src/data-structures/binary-tree/diagrams/avl-tree-inserting.gif)
267
+
268
+
269
+ ![](src/data-structures/graph/diagrams/tarjan.webp)
270
+
271
+ ![](src/data-structures/graph/diagrams/adjacency-list.jpg)
272
+
273
+ ![](src/data-structures/graph/diagrams/adjacency-list-pros-cons.jpg)
274
+
275
+ ![](src/data-structures/graph/diagrams/adjacency-matrix.jpg)
276
+
277
+ ![](src/data-structures/graph/diagrams/adjacency-matrix-pros-cons.jpg)
278
+
279
+ ![](src/data-structures/graph/diagrams/dfs-can-do.jpg)
280
+
281
+ ![](src/data-structures/graph/diagrams/edge-list.jpg)
282
+
283
+ ![](src/data-structures/graph/diagrams/edge-list-pros-cons.jpg)
284
+
285
+ ![](src/data-structures/graph/diagrams/max-flow.jpg)
286
+
287
+ ![](src/data-structures/graph/diagrams/mst.jpg)
288
+
289
+ [//]: # (![]&#40;src/data-structures/graph/diagrams/tarjan-articulation-point-bridge.png&#41;)
290
+
291
+ [//]: # (![]&#40;src/data-structures/graph/diagrams/tarjan-complicate-simple.png&#41;)
292
+
293
+ [//]: # (![]&#40;src/data-structures/graph/diagrams/tarjan-strongly-connected-component.png&#41;)
294
+
295
+
296
+
297
+
298
+
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @copyright 2030 Tyler Zeng <zrwusa@gmail.com>
3
+ * @license MIT
4
+ */
1
5
  import { BST, BSTNode } from './bst';
2
6
  import type { AVLTreeDeleted, BinaryTreeNodeId } from '../types';
3
7
  export declare class AVLTreeNode<T> extends BSTNode<T> {
@@ -5,13 +9,66 @@ export declare class AVLTreeNode<T> extends BSTNode<T> {
5
9
  }
6
10
  export declare class AVLTree<T> extends BST<T> {
7
11
  createNode(id: BinaryTreeNodeId, val: T, count?: number): AVLTreeNode<T>;
12
+ /**
13
+ * The function overrides the put method of a Binary Search Tree to insert a node with a given id and value, and then
14
+ * balances the tree.
15
+ * @param {BinaryTreeNodeId} id - The `id` parameter is the identifier of the binary tree node that we want to put or
16
+ * update in the AVL tree.
17
+ * @param {T | null} val - The `val` parameter represents the value that you want to assign to the node with the given
18
+ * `id`. It can be of type `T` (the generic type) or `null`.
19
+ * @param {number} [count] - The `count` parameter is an optional parameter of type `number`. It represents the number
20
+ * of times the value `val` should be inserted into the AVL tree. If the `count` parameter is not provided, it defaults
21
+ * to `1`, indicating that the value should be inserted once.
22
+ * @returns The method is returning either an AVLTreeNode<T> object or null.
23
+ */
8
24
  put(id: BinaryTreeNodeId, val: T | null, count?: number): AVLTreeNode<T> | null;
25
+ /**
26
+ * The function overrides the remove method of the Binary Search Tree class, performs the removal operation, and
27
+ * then balances the tree if necessary.
28
+ * @param {BinaryTreeNodeId} id - The `id` parameter represents the identifier of the binary tree node that needs to be
29
+ * removed from the AVL tree.
30
+ * @param {boolean} [isUpdateAllLeftSum] - The `isUpdateAllLeftSum` parameter is an optional boolean parameter that
31
+ * determines whether the left sum of all nodes in the AVL tree should be updated after removing a node. If
32
+ * `isUpdateAllLeftSum` is set to `true`, the left sum of all nodes will be recalculated.
33
+ * @returns The method is returning an array of `AVLTreeDeleted<T>` objects.
34
+ */
9
35
  remove(id: BinaryTreeNodeId, isUpdateAllLeftSum?: boolean): AVLTreeDeleted<T>[];
36
+ /**
37
+ * The balance factor of a given AVL tree node is calculated by subtracting the height of its left subtree from the
38
+ * height of its right subtree.
39
+ * @param node - The parameter "node" is of type AVLTreeNode<T>, which represents a node in an AVL tree.
40
+ * @returns The balance factor of the given AVL tree node.
41
+ */
10
42
  balanceFactor(node: AVLTreeNode<T>): number;
43
+ /**
44
+ * The function updates the height of a node in an AVL tree based on the heights of its left and right subtrees.
45
+ * @param node - The parameter `node` is an AVLTreeNode object, which represents a node in an AVL tree.
46
+ */
11
47
  updateHeight(node: AVLTreeNode<T>): void;
48
+ /**
49
+ * The `balancePath` function balances the AVL tree by performing appropriate rotations based on the balance factor of
50
+ * each node in the path from the given node to the root.
51
+ * @param node - The `node` parameter is an AVLTreeNode object, which represents a node in an AVL tree.
52
+ */
12
53
  balancePath(node: AVLTreeNode<T>): void;
54
+ /**
55
+ * The `balanceLL` function performs a left-left rotation on an AVL tree to balance it.
56
+ * @param A - The parameter A is an AVLTreeNode object.
57
+ */
13
58
  balanceLL(A: AVLTreeNode<T>): void;
59
+ /**
60
+ * The `balanceLR` function performs a left-right rotation to balance an AVL tree.
61
+ * @param A - A is an AVLTreeNode object.
62
+ */
14
63
  balanceLR(A: AVLTreeNode<T>): void;
64
+ /**
65
+ * The `balanceRR` function performs a right-right rotation on an AVL tree to balance it.
66
+ * @param A - The parameter A is an AVLTreeNode object.
67
+ */
15
68
  balanceRR(A: AVLTreeNode<T>): void;
69
+ /**
70
+ * The `balanceRL` function performs a right-left rotation to balance an AVL tree.
71
+ * @param A - A is an AVLTreeNode object.
72
+ */
16
73
  balanceRL(A: AVLTreeNode<T>): void;
17
74
  }