tree-set-typed 2.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 (273) hide show
  1. package/.eslintrc.js +61 -0
  2. package/.prettierignore +6 -0
  3. package/.prettierrc.js +16 -0
  4. package/LICENSE +21 -0
  5. package/README.md +482 -0
  6. package/coverage/clover.xml +13 -0
  7. package/coverage/coverage-final.json +96 -0
  8. package/coverage/coverage-summary.json +60 -0
  9. package/coverage/lcov-report/base.css +403 -0
  10. package/coverage/lcov-report/block-navigation.js +87 -0
  11. package/coverage/lcov-report/favicon.png +0 -0
  12. package/coverage/lcov-report/index.html +119 -0
  13. package/coverage/lcov-report/index.ts.html +109 -0
  14. package/coverage/lcov-report/prettify.css +1 -0
  15. package/coverage/lcov-report/prettify.js +2 -0
  16. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  17. package/coverage/lcov-report/sorter.js +206 -0
  18. package/coverage/lcov.info +14 -0
  19. package/dist/cjs/index.cjs +12 -0
  20. package/dist/cjs/index.cjs.map +1 -0
  21. package/dist/cjs-legacy/index.cjs +12 -0
  22. package/dist/cjs-legacy/index.cjs.map +1 -0
  23. package/dist/esm/index.mjs +3 -0
  24. package/dist/esm/index.mjs.map +1 -0
  25. package/dist/esm-legacy/index.mjs +3 -0
  26. package/dist/esm-legacy/index.mjs.map +1 -0
  27. package/dist/types/common/index.d.ts +12 -0
  28. package/dist/types/constants/index.d.ts +4 -0
  29. package/dist/types/data-structures/base/index.d.ts +2 -0
  30. package/dist/types/data-structures/base/iterable-element-base.d.ts +219 -0
  31. package/dist/types/data-structures/base/iterable-entry-base.d.ts +150 -0
  32. package/dist/types/data-structures/base/linear-base.d.ts +335 -0
  33. package/dist/types/data-structures/binary-tree/avl-tree-counter.d.ts +236 -0
  34. package/dist/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +197 -0
  35. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +440 -0
  36. package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +174 -0
  37. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +807 -0
  38. package/dist/types/data-structures/binary-tree/bst.d.ts +645 -0
  39. package/dist/types/data-structures/binary-tree/index.d.ts +10 -0
  40. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +312 -0
  41. package/dist/types/data-structures/binary-tree/segment-tree.d.ts +160 -0
  42. package/dist/types/data-structures/binary-tree/tree-counter.d.ts +243 -0
  43. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +333 -0
  44. package/dist/types/data-structures/graph/abstract-graph.d.ts +340 -0
  45. package/dist/types/data-structures/graph/directed-graph.d.ts +332 -0
  46. package/dist/types/data-structures/graph/index.d.ts +4 -0
  47. package/dist/types/data-structures/graph/map-graph.d.ts +78 -0
  48. package/dist/types/data-structures/graph/undirected-graph.d.ts +347 -0
  49. package/dist/types/data-structures/hash/hash-map.d.ts +428 -0
  50. package/dist/types/data-structures/hash/index.d.ts +1 -0
  51. package/dist/types/data-structures/heap/heap.d.ts +552 -0
  52. package/dist/types/data-structures/heap/index.d.ts +3 -0
  53. package/dist/types/data-structures/heap/max-heap.d.ts +32 -0
  54. package/dist/types/data-structures/heap/min-heap.d.ts +33 -0
  55. package/dist/types/data-structures/index.d.ts +12 -0
  56. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +437 -0
  57. package/dist/types/data-structures/linked-list/index.d.ts +3 -0
  58. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +567 -0
  59. package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +27 -0
  60. package/dist/types/data-structures/matrix/index.d.ts +2 -0
  61. package/dist/types/data-structures/matrix/matrix.d.ts +168 -0
  62. package/dist/types/data-structures/matrix/navigator.d.ts +55 -0
  63. package/dist/types/data-structures/priority-queue/index.d.ts +3 -0
  64. package/dist/types/data-structures/priority-queue/max-priority-queue.d.ts +27 -0
  65. package/dist/types/data-structures/priority-queue/min-priority-queue.d.ts +26 -0
  66. package/dist/types/data-structures/priority-queue/priority-queue.d.ts +15 -0
  67. package/dist/types/data-structures/queue/deque.d.ts +459 -0
  68. package/dist/types/data-structures/queue/index.d.ts +2 -0
  69. package/dist/types/data-structures/queue/queue.d.ts +364 -0
  70. package/dist/types/data-structures/stack/index.d.ts +1 -0
  71. package/dist/types/data-structures/stack/stack.d.ts +324 -0
  72. package/dist/types/data-structures/tree/index.d.ts +1 -0
  73. package/dist/types/data-structures/tree/tree.d.ts +62 -0
  74. package/dist/types/data-structures/trie/index.d.ts +1 -0
  75. package/dist/types/data-structures/trie/trie.d.ts +412 -0
  76. package/dist/types/index.d.ts +23 -0
  77. package/dist/types/interfaces/binary-tree.d.ts +60 -0
  78. package/dist/types/interfaces/doubly-linked-list.d.ts +1 -0
  79. package/dist/types/interfaces/graph.d.ts +21 -0
  80. package/dist/types/interfaces/heap.d.ts +1 -0
  81. package/dist/types/interfaces/index.d.ts +8 -0
  82. package/dist/types/interfaces/navigator.d.ts +1 -0
  83. package/dist/types/interfaces/priority-queue.d.ts +1 -0
  84. package/dist/types/interfaces/segment-tree.d.ts +1 -0
  85. package/dist/types/interfaces/singly-linked-list.d.ts +1 -0
  86. package/dist/types/types/common.d.ts +15 -0
  87. package/dist/types/types/data-structures/base/base.d.ts +13 -0
  88. package/dist/types/types/data-structures/base/index.d.ts +1 -0
  89. package/dist/types/types/data-structures/binary-tree/avl-tree-counter.d.ts +2 -0
  90. package/dist/types/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +2 -0
  91. package/dist/types/types/data-structures/binary-tree/avl-tree.d.ts +2 -0
  92. package/dist/types/types/data-structures/binary-tree/binary-indexed-tree.d.ts +1 -0
  93. package/dist/types/types/data-structures/binary-tree/binary-tree.d.ts +29 -0
  94. package/dist/types/types/data-structures/binary-tree/bst.d.ts +12 -0
  95. package/dist/types/types/data-structures/binary-tree/index.d.ts +9 -0
  96. package/dist/types/types/data-structures/binary-tree/red-black-tree.d.ts +3 -0
  97. package/dist/types/types/data-structures/binary-tree/segment-tree.d.ts +1 -0
  98. package/dist/types/types/data-structures/binary-tree/tree-counter.d.ts +2 -0
  99. package/dist/types/types/data-structures/binary-tree/tree-multi-map.d.ts +2 -0
  100. package/dist/types/types/data-structures/graph/abstract-graph.d.ts +14 -0
  101. package/dist/types/types/data-structures/graph/directed-graph.d.ts +1 -0
  102. package/dist/types/types/data-structures/graph/index.d.ts +3 -0
  103. package/dist/types/types/data-structures/graph/map-graph.d.ts +1 -0
  104. package/dist/types/types/data-structures/graph/undirected-graph.d.ts +1 -0
  105. package/dist/types/types/data-structures/hash/hash-map.d.ts +19 -0
  106. package/dist/types/types/data-structures/hash/index.d.ts +2 -0
  107. package/dist/types/types/data-structures/heap/heap.d.ts +5 -0
  108. package/dist/types/types/data-structures/heap/index.d.ts +1 -0
  109. package/dist/types/types/data-structures/heap/max-heap.d.ts +1 -0
  110. package/dist/types/types/data-structures/heap/min-heap.d.ts +1 -0
  111. package/dist/types/types/data-structures/index.d.ts +12 -0
  112. package/dist/types/types/data-structures/linked-list/doubly-linked-list.d.ts +2 -0
  113. package/dist/types/types/data-structures/linked-list/index.d.ts +3 -0
  114. package/dist/types/types/data-structures/linked-list/singly-linked-list.d.ts +2 -0
  115. package/dist/types/types/data-structures/linked-list/skip-linked-list.d.ts +4 -0
  116. package/dist/types/types/data-structures/matrix/index.d.ts +2 -0
  117. package/dist/types/types/data-structures/matrix/matrix.d.ts +7 -0
  118. package/dist/types/types/data-structures/matrix/navigator.d.ts +14 -0
  119. package/dist/types/types/data-structures/priority-queue/index.d.ts +3 -0
  120. package/dist/types/types/data-structures/priority-queue/max-priority-queue.d.ts +1 -0
  121. package/dist/types/types/data-structures/priority-queue/min-priority-queue.d.ts +1 -0
  122. package/dist/types/types/data-structures/priority-queue/priority-queue.d.ts +2 -0
  123. package/dist/types/types/data-structures/queue/deque.d.ts +4 -0
  124. package/dist/types/types/data-structures/queue/index.d.ts +2 -0
  125. package/dist/types/types/data-structures/queue/queue.d.ts +4 -0
  126. package/dist/types/types/data-structures/stack/index.d.ts +1 -0
  127. package/dist/types/types/data-structures/stack/stack.d.ts +2 -0
  128. package/dist/types/types/data-structures/tree/index.d.ts +1 -0
  129. package/dist/types/types/data-structures/tree/tree.d.ts +1 -0
  130. package/dist/types/types/data-structures/trie/index.d.ts +1 -0
  131. package/dist/types/types/data-structures/trie/trie.d.ts +4 -0
  132. package/dist/types/types/index.d.ts +3 -0
  133. package/dist/types/types/utils/index.d.ts +2 -0
  134. package/dist/types/types/utils/utils.d.ts +22 -0
  135. package/dist/types/types/utils/validate-type.d.ts +19 -0
  136. package/dist/types/utils/index.d.ts +2 -0
  137. package/dist/types/utils/number.d.ts +14 -0
  138. package/dist/types/utils/utils.d.ts +209 -0
  139. package/dist/umd/red-black-tree-typed.js +14578 -0
  140. package/dist/umd/red-black-tree-typed.js.map +1 -0
  141. package/dist/umd/red-black-tree-typed.min.js +44 -0
  142. package/dist/umd/red-black-tree-typed.min.js.map +1 -0
  143. package/docs/.nojekyll +1 -0
  144. package/docs/assets/highlight.css +92 -0
  145. package/docs/assets/main.js +59 -0
  146. package/docs/assets/navigation.js +1 -0
  147. package/docs/assets/search.js +1 -0
  148. package/docs/assets/style.css +1383 -0
  149. package/docs/classes/AVLTree.html +2046 -0
  150. package/docs/classes/AVLTreeNode.html +263 -0
  151. package/docs/index.html +523 -0
  152. package/docs/modules.html +45 -0
  153. package/jest.config.js +8 -0
  154. package/package.json +113 -0
  155. package/src/common/index.ts +23 -0
  156. package/src/constants/index.ts +4 -0
  157. package/src/data-structures/base/index.ts +2 -0
  158. package/src/data-structures/base/iterable-element-base.ts +352 -0
  159. package/src/data-structures/base/iterable-entry-base.ts +246 -0
  160. package/src/data-structures/base/linear-base.ts +643 -0
  161. package/src/data-structures/binary-tree/avl-tree-counter.ts +539 -0
  162. package/src/data-structures/binary-tree/avl-tree-multi-map.ts +438 -0
  163. package/src/data-structures/binary-tree/avl-tree.ts +840 -0
  164. package/src/data-structures/binary-tree/binary-indexed-tree.ts +331 -0
  165. package/src/data-structures/binary-tree/binary-tree.ts +2492 -0
  166. package/src/data-structures/binary-tree/bst.ts +2024 -0
  167. package/src/data-structures/binary-tree/index.ts +10 -0
  168. package/src/data-structures/binary-tree/red-black-tree.ts +767 -0
  169. package/src/data-structures/binary-tree/segment-tree.ts +324 -0
  170. package/src/data-structures/binary-tree/tree-counter.ts +575 -0
  171. package/src/data-structures/binary-tree/tree-multi-map.ts +549 -0
  172. package/src/data-structures/graph/abstract-graph.ts +1081 -0
  173. package/src/data-structures/graph/directed-graph.ts +715 -0
  174. package/src/data-structures/graph/index.ts +4 -0
  175. package/src/data-structures/graph/map-graph.ts +132 -0
  176. package/src/data-structures/graph/undirected-graph.ts +626 -0
  177. package/src/data-structures/hash/hash-map.ts +813 -0
  178. package/src/data-structures/hash/index.ts +1 -0
  179. package/src/data-structures/heap/heap.ts +1020 -0
  180. package/src/data-structures/heap/index.ts +3 -0
  181. package/src/data-structures/heap/max-heap.ts +47 -0
  182. package/src/data-structures/heap/min-heap.ts +36 -0
  183. package/src/data-structures/index.ts +12 -0
  184. package/src/data-structures/linked-list/doubly-linked-list.ts +876 -0
  185. package/src/data-structures/linked-list/index.ts +3 -0
  186. package/src/data-structures/linked-list/singly-linked-list.ts +1050 -0
  187. package/src/data-structures/linked-list/skip-linked-list.ts +173 -0
  188. package/src/data-structures/matrix/index.ts +2 -0
  189. package/src/data-structures/matrix/matrix.ts +491 -0
  190. package/src/data-structures/matrix/navigator.ts +124 -0
  191. package/src/data-structures/priority-queue/index.ts +3 -0
  192. package/src/data-structures/priority-queue/max-priority-queue.ts +42 -0
  193. package/src/data-structures/priority-queue/min-priority-queue.ts +29 -0
  194. package/src/data-structures/priority-queue/priority-queue.ts +19 -0
  195. package/src/data-structures/queue/deque.ts +1001 -0
  196. package/src/data-structures/queue/index.ts +2 -0
  197. package/src/data-structures/queue/queue.ts +592 -0
  198. package/src/data-structures/stack/index.ts +1 -0
  199. package/src/data-structures/stack/stack.ts +469 -0
  200. package/src/data-structures/tree/index.ts +1 -0
  201. package/src/data-structures/tree/tree.ts +115 -0
  202. package/src/data-structures/trie/index.ts +1 -0
  203. package/src/data-structures/trie/trie.ts +756 -0
  204. package/src/index.ts +24 -0
  205. package/src/interfaces/binary-tree.ts +252 -0
  206. package/src/interfaces/doubly-linked-list.ts +1 -0
  207. package/src/interfaces/graph.ts +44 -0
  208. package/src/interfaces/heap.ts +1 -0
  209. package/src/interfaces/index.ts +8 -0
  210. package/src/interfaces/navigator.ts +1 -0
  211. package/src/interfaces/priority-queue.ts +1 -0
  212. package/src/interfaces/segment-tree.ts +1 -0
  213. package/src/interfaces/singly-linked-list.ts +1 -0
  214. package/src/types/common.ts +25 -0
  215. package/src/types/data-structures/base/base.ts +34 -0
  216. package/src/types/data-structures/base/index.ts +1 -0
  217. package/src/types/data-structures/binary-tree/avl-tree-counter.ts +3 -0
  218. package/src/types/data-structures/binary-tree/avl-tree-multi-map.ts +3 -0
  219. package/src/types/data-structures/binary-tree/avl-tree.ts +3 -0
  220. package/src/types/data-structures/binary-tree/binary-indexed-tree.ts +1 -0
  221. package/src/types/data-structures/binary-tree/binary-tree.ts +31 -0
  222. package/src/types/data-structures/binary-tree/bst.ts +19 -0
  223. package/src/types/data-structures/binary-tree/index.ts +9 -0
  224. package/src/types/data-structures/binary-tree/red-black-tree.ts +5 -0
  225. package/src/types/data-structures/binary-tree/segment-tree.ts +1 -0
  226. package/src/types/data-structures/binary-tree/tree-counter.ts +3 -0
  227. package/src/types/data-structures/binary-tree/tree-multi-map.ts +3 -0
  228. package/src/types/data-structures/graph/abstract-graph.ts +18 -0
  229. package/src/types/data-structures/graph/directed-graph.ts +2 -0
  230. package/src/types/data-structures/graph/index.ts +3 -0
  231. package/src/types/data-structures/graph/map-graph.ts +1 -0
  232. package/src/types/data-structures/graph/undirected-graph.ts +1 -0
  233. package/src/types/data-structures/hash/hash-map.ts +19 -0
  234. package/src/types/data-structures/hash/index.ts +3 -0
  235. package/src/types/data-structures/heap/heap.ts +6 -0
  236. package/src/types/data-structures/heap/index.ts +1 -0
  237. package/src/types/data-structures/heap/max-heap.ts +1 -0
  238. package/src/types/data-structures/heap/min-heap.ts +1 -0
  239. package/src/types/data-structures/index.ts +12 -0
  240. package/src/types/data-structures/linked-list/doubly-linked-list.ts +3 -0
  241. package/src/types/data-structures/linked-list/index.ts +3 -0
  242. package/src/types/data-structures/linked-list/singly-linked-list.ts +3 -0
  243. package/src/types/data-structures/linked-list/skip-linked-list.ts +1 -0
  244. package/src/types/data-structures/matrix/index.ts +2 -0
  245. package/src/types/data-structures/matrix/matrix.ts +7 -0
  246. package/src/types/data-structures/matrix/navigator.ts +14 -0
  247. package/src/types/data-structures/priority-queue/index.ts +3 -0
  248. package/src/types/data-structures/priority-queue/max-priority-queue.ts +1 -0
  249. package/src/types/data-structures/priority-queue/min-priority-queue.ts +1 -0
  250. package/src/types/data-structures/priority-queue/priority-queue.ts +3 -0
  251. package/src/types/data-structures/queue/deque.ts +5 -0
  252. package/src/types/data-structures/queue/index.ts +2 -0
  253. package/src/types/data-structures/queue/queue.ts +5 -0
  254. package/src/types/data-structures/stack/index.ts +1 -0
  255. package/src/types/data-structures/stack/stack.ts +3 -0
  256. package/src/types/data-structures/tree/index.ts +1 -0
  257. package/src/types/data-structures/tree/tree.ts +1 -0
  258. package/src/types/data-structures/trie/index.ts +1 -0
  259. package/src/types/data-structures/trie/trie.ts +3 -0
  260. package/src/types/index.ts +3 -0
  261. package/src/types/utils/index.ts +2 -0
  262. package/src/types/utils/utils.ts +33 -0
  263. package/src/types/utils/validate-type.ts +35 -0
  264. package/src/utils/index.ts +2 -0
  265. package/src/utils/number.ts +22 -0
  266. package/src/utils/utils.ts +350 -0
  267. package/test/index.test.ts +111 -0
  268. package/tsconfig.base.json +23 -0
  269. package/tsconfig.json +12 -0
  270. package/tsconfig.test.json +8 -0
  271. package/tsconfig.types.json +15 -0
  272. package/tsup.config.js +28 -0
  273. package/tsup.node.config.js +71 -0
@@ -0,0 +1,45 @@
1
+ <!DOCTYPE html><html class="default" lang="en"><head><meta charSet="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>red-black-tree-typed</title><meta name="description" content="Documentation for red-black-tree-typed"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="assets/style.css"/><link rel="stylesheet" href="assets/highlight.css"/><script defer src="assets/main.js"></script><script async src="assets/search.js" id="tsd-search-script"></script><script async src="assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os"</script><header class="tsd-page-toolbar">
2
+ <div class="tsd-toolbar-contents container">
3
+ <div class="table-cell" id="tsd-search" data-base=".">
4
+ <div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="#icon-search"></use></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div>
5
+ <div class="field">
6
+ <div id="tsd-toolbar-links"></div></div>
7
+ <ul class="results">
8
+ <li class="state loading">Preparing search index...</li>
9
+ <li class="state failure">The search index is not available</li></ul><a href="index.html" class="title">red-black-tree-typed</a></div>
10
+ <div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="#icon-menu"></use></svg></a></div></div></header>
11
+ <div class="container container-main">
12
+ <div class="col-content">
13
+ <div class="tsd-page-title">
14
+ <h2>red-black-tree-typed</h2></div>
15
+ <section class="tsd-panel-group tsd-index-group">
16
+ <section class="tsd-panel tsd-index-panel">
17
+ <h3 class="tsd-index-heading uppercase">Index</h3>
18
+ <section class="tsd-index-section">
19
+ <h3 class="tsd-index-heading">Classes</h3>
20
+ <div class="tsd-index-list"><a href="classes/AVLTree.html" class="tsd-index-link tsd-is-external"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-128"></use></svg><span>AVLTree</span></a>
21
+ <a href="classes/AVLTreeNode.html" class="tsd-index-link tsd-is-external"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-128"></use></svg><span>AVLTree<wbr/>Node</span></a>
22
+ </div></section></section></section></div>
23
+ <div class="col-sidebar">
24
+ <div class="page-menu">
25
+ <div class="tsd-navigation settings">
26
+ <details class="tsd-index-accordion"><summary class="tsd-accordion-summary">
27
+ <h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="#icon-chevronDown"></use></svg>Settings</h3></summary>
28
+ <div class="tsd-accordion-details">
29
+ <div class="tsd-filter-visibility">
30
+ <h4 class="uppercase">Member Visibility</h4><form>
31
+ <ul id="tsd-filter-options">
32
+ <li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><use href="#icon-checkbox"></use></svg><span>Protected</span></label></li>
33
+ <li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-private" name="private"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><use href="#icon-checkbox"></use></svg><span>Private</span></label></li>
34
+ <li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><use href="#icon-checkbox"></use></svg><span>Inherited</span></label></li>
35
+ <li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-external" name="external"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><use href="#icon-checkbox"></use></svg><span>External</span></label></li></ul></form></div>
36
+ <div class="tsd-theme-toggle">
37
+ <h4 class="uppercase">Theme</h4><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div></div>
38
+ <div class="site-menu">
39
+ <nav class="tsd-navigation"><a href="modules.html" class="current"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-1"></use></svg><span>red-black-tree-typed</span></a>
40
+ <ul class="tsd-small-nested-navigation" id="tsd-nav-container" data-base=".">
41
+ <li><a href="classes/AVLTree.html" class="tsd-is-external"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-128"></use></svg>AVLTree</a></li>
42
+ <li><a href="classes/AVLTreeNode.html" class="tsd-is-external"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-128"></use></svg>AVLTreeNode</a></li></ul></nav></div></div></div>
43
+ <div class="tsd-generator">
44
+ <p>Generated using <a href="https://typedoc.org/" rel="noopener" target="_blank">TypeDoc</a></p></div>
45
+ <div class="overlay"></div><svg style="display: none"><g id="icon-1"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-namespace)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><path d="M9.33 16V7.24H10.77L13.446 14.74C13.43 14.54 13.41 14.296 13.386 14.008C13.37 13.712 13.354 13.404 13.338 13.084C13.33 12.756 13.326 12.448 13.326 12.16V7.24H14.37V16H12.93L10.266 8.5C10.282 8.692 10.298 8.936 10.314 9.232C10.33 9.52 10.342 9.828 10.35 10.156C10.366 10.476 10.374 10.784 10.374 11.08V16H9.33Z" fill="var(--color-text)"></path></g><g id="icon-2"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-namespace)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><path d="M9.33 16V7.24H10.77L13.446 14.74C13.43 14.54 13.41 14.296 13.386 14.008C13.37 13.712 13.354 13.404 13.338 13.084C13.33 12.756 13.326 12.448 13.326 12.16V7.24H14.37V16H12.93L10.266 8.5C10.282 8.692 10.298 8.936 10.314 9.232C10.33 9.52 10.342 9.828 10.35 10.156C10.366 10.476 10.374 10.784 10.374 11.08V16H9.33Z" fill="var(--color-text)"></path></g><g id="icon-4"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-namespace)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><path d="M9.33 16V7.24H10.77L13.446 14.74C13.43 14.54 13.41 14.296 13.386 14.008C13.37 13.712 13.354 13.404 13.338 13.084C13.33 12.756 13.326 12.448 13.326 12.16V7.24H14.37V16H12.93L10.266 8.5C10.282 8.692 10.298 8.936 10.314 9.232C10.33 9.52 10.342 9.828 10.35 10.156C10.366 10.476 10.374 10.784 10.374 11.08V16H9.33Z" fill="var(--color-text)"></path></g><g id="icon-8"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-enum)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><path d="M9.45 16V7.24H14.49V8.224H10.518V10.936H14.07V11.908H10.518V15.016H14.49V16H9.45Z" fill="var(--color-text)"></path></g><g id="icon-16"><rect fill="var(--color-icon-background)" stroke="#FF984D" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="12"></rect><path d="M9.354 16V7.24H12.174C12.99 7.24 13.638 7.476 14.118 7.948C14.606 8.412 14.85 9.036 14.85 9.82C14.85 10.604 14.606 11.232 14.118 11.704C13.638 12.168 12.99 12.4 12.174 12.4H10.434V16H9.354ZM10.434 11.428H12.174C12.646 11.428 13.022 11.284 13.302 10.996C13.59 10.7 13.734 10.308 13.734 9.82C13.734 9.324 13.59 8.932 13.302 8.644C13.022 8.356 12.646 8.212 12.174 8.212H10.434V11.428Z" fill="var(--color-text)"></path></g><g id="icon-32"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-variable)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><path d="M11.106 16L8.85 7.24H9.966L11.454 13.192C11.558 13.608 11.646 13.996 11.718 14.356C11.79 14.708 11.842 14.976 11.874 15.16C11.906 14.976 11.954 14.708 12.018 14.356C12.09 13.996 12.178 13.608 12.282 13.192L13.758 7.24H14.85L12.582 16H11.106Z" fill="var(--color-text)"></path></g><g id="icon-64"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-function)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><path d="M9.39 16V7.24H14.55V8.224H10.446V11.128H14.238V12.112H10.47V16H9.39Z" fill="var(--color-text)"></path></g><g id="icon-128"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-class)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><path d="M11.898 16.1201C11.098 16.1201 10.466 15.8961 10.002 15.4481C9.53803 15.0001 9.30603 14.3841 9.30603 13.6001V9.64012C9.30603 8.85612 9.53803 8.24012 10.002 7.79212C10.466 7.34412 11.098 7.12012 11.898 7.12012C12.682 7.12012 13.306 7.34812 13.77 7.80412C14.234 8.25212 14.466 8.86412 14.466 9.64012H13.386C13.386 9.14412 13.254 8.76412 12.99 8.50012C12.734 8.22812 12.37 8.09212 11.898 8.09212C11.426 8.09212 11.054 8.22412 10.782 8.48812C10.518 8.75212 10.386 9.13212 10.386 9.62812V13.6001C10.386 14.0961 10.518 14.4801 10.782 14.7521C11.054 15.0161 11.426 15.1481 11.898 15.1481C12.37 15.1481 12.734 15.0161 12.99 14.7521C13.254 14.4801 13.386 14.0961 13.386 13.6001H14.466C14.466 14.3761 14.234 14.9921 13.77 15.4481C13.306 15.8961 12.682 16.1201 11.898 16.1201Z" fill="var(--color-text)"></path></g><g id="icon-256"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-interface)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><path d="M9.51 16V15.016H11.298V8.224H9.51V7.24H14.19V8.224H12.402V15.016H14.19V16H9.51Z" fill="var(--color-text)"></path></g><g id="icon-512"><rect fill="var(--color-icon-background)" stroke="#4D7FFF" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="12"></rect><path d="M11.898 16.1201C11.098 16.1201 10.466 15.8961 10.002 15.4481C9.53803 15.0001 9.30603 14.3841 9.30603 13.6001V9.64012C9.30603 8.85612 9.53803 8.24012 10.002 7.79212C10.466 7.34412 11.098 7.12012 11.898 7.12012C12.682 7.12012 13.306 7.34812 13.77 7.80412C14.234 8.25212 14.466 8.86412 14.466 9.64012H13.386C13.386 9.14412 13.254 8.76412 12.99 8.50012C12.734 8.22812 12.37 8.09212 11.898 8.09212C11.426 8.09212 11.054 8.22412 10.782 8.48812C10.518 8.75212 10.386 9.13212 10.386 9.62812V13.6001C10.386 14.0961 10.518 14.4801 10.782 14.7521C11.054 15.0161 11.426 15.1481 11.898 15.1481C12.37 15.1481 12.734 15.0161 12.99 14.7521C13.254 14.4801 13.386 14.0961 13.386 13.6001H14.466C14.466 14.3761 14.234 14.9921 13.77 15.4481C13.306 15.8961 12.682 16.1201 11.898 16.1201Z" fill="var(--color-text)"></path></g><g id="icon-1024"><rect fill="var(--color-icon-background)" stroke="#FF984D" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="12"></rect><path d="M9.354 16V7.24H12.174C12.99 7.24 13.638 7.476 14.118 7.948C14.606 8.412 14.85 9.036 14.85 9.82C14.85 10.604 14.606 11.232 14.118 11.704C13.638 12.168 12.99 12.4 12.174 12.4H10.434V16H9.354ZM10.434 11.428H12.174C12.646 11.428 13.022 11.284 13.302 10.996C13.59 10.7 13.734 10.308 13.734 9.82C13.734 9.324 13.59 8.932 13.302 8.644C13.022 8.356 12.646 8.212 12.174 8.212H10.434V11.428Z" fill="var(--color-text)"></path></g><g id="icon-2048"><rect fill="var(--color-icon-background)" stroke="#FF4DB8" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="12"></rect><path d="M9.162 16V7.24H10.578L11.514 10.072C11.602 10.328 11.674 10.584 11.73 10.84C11.794 11.088 11.842 11.28 11.874 11.416C11.906 11.28 11.954 11.088 12.018 10.84C12.082 10.584 12.154 10.324 12.234 10.06L13.122 7.24H14.538V16H13.482V12.82C13.482 12.468 13.49 12.068 13.506 11.62C13.53 11.172 13.558 10.716 13.59 10.252C13.622 9.78 13.654 9.332 13.686 8.908C13.726 8.476 13.762 8.1 13.794 7.78L12.366 12.16H11.334L9.894 7.78C9.934 8.092 9.97 8.456 10.002 8.872C10.042 9.28 10.078 9.716 10.11 10.18C10.142 10.636 10.166 11.092 10.182 11.548C10.206 12.004 10.218 12.428 10.218 12.82V16H9.162Z" fill="var(--color-text)"></path></g><g id="icon-4096"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-function)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><path d="M9.39 16V7.24H14.55V8.224H10.446V11.128H14.238V12.112H10.47V16H9.39Z" fill="var(--color-text)"></path></g><g id="icon-8192"><rect fill="var(--color-icon-background)" stroke="#FF984D" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="12"></rect><path d="M9.354 16V7.24H12.174C12.99 7.24 13.638 7.476 14.118 7.948C14.606 8.412 14.85 9.036 14.85 9.82C14.85 10.604 14.606 11.232 14.118 11.704C13.638 12.168 12.99 12.4 12.174 12.4H10.434V16H9.354ZM10.434 11.428H12.174C12.646 11.428 13.022 11.284 13.302 10.996C13.59 10.7 13.734 10.308 13.734 9.82C13.734 9.324 13.59 8.932 13.302 8.644C13.022 8.356 12.646 8.212 12.174 8.212H10.434V11.428Z" fill="var(--color-text)"></path></g><g id="icon-16384"><rect fill="var(--color-icon-background)" stroke="#4D7FFF" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="12"></rect><path d="M11.898 16.1201C11.098 16.1201 10.466 15.8961 10.002 15.4481C9.53803 15.0001 9.30603 14.3841 9.30603 13.6001V9.64012C9.30603 8.85612 9.53803 8.24012 10.002 7.79212C10.466 7.34412 11.098 7.12012 11.898 7.12012C12.682 7.12012 13.306 7.34812 13.77 7.80412C14.234 8.25212 14.466 8.86412 14.466 9.64012H13.386C13.386 9.14412 13.254 8.76412 12.99 8.50012C12.734 8.22812 12.37 8.09212 11.898 8.09212C11.426 8.09212 11.054 8.22412 10.782 8.48812C10.518 8.75212 10.386 9.13212 10.386 9.62812V13.6001C10.386 14.0961 10.518 14.4801 10.782 14.7521C11.054 15.0161 11.426 15.1481 11.898 15.1481C12.37 15.1481 12.734 15.0161 12.99 14.7521C13.254 14.4801 13.386 14.0961 13.386 13.6001H14.466C14.466 14.3761 14.234 14.9921 13.77 15.4481C13.306 15.8961 12.682 16.1201 11.898 16.1201Z" fill="var(--color-text)"></path></g><g id="icon-32768"><rect fill="var(--color-icon-background)" stroke="#FF984D" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="12"></rect><path d="M9.354 16V7.24H12.174C12.99 7.24 13.638 7.476 14.118 7.948C14.606 8.412 14.85 9.036 14.85 9.82C14.85 10.604 14.606 11.232 14.118 11.704C13.638 12.168 12.99 12.4 12.174 12.4H10.434V16H9.354ZM10.434 11.428H12.174C12.646 11.428 13.022 11.284 13.302 10.996C13.59 10.7 13.734 10.308 13.734 9.82C13.734 9.324 13.59 8.932 13.302 8.644C13.022 8.356 12.646 8.212 12.174 8.212H10.434V11.428Z" fill="var(--color-text)"></path></g><g id="icon-65536"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-type-alias)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><path d="M11.31 16V8.224H8.91V7.24H14.79V8.224H12.39V16H11.31Z" fill="var(--color-text)"></path></g><g id="icon-131072"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-type-alias)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><path d="M11.31 16V8.224H8.91V7.24H14.79V8.224H12.39V16H11.31Z" fill="var(--color-text)"></path></g><g id="icon-262144"><rect fill="var(--color-icon-background)" stroke="#FF4D4D" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="12"></rect><path d="M8.85 16L11.13 7.24H12.582L14.85 16H13.758L13.182 13.672H10.53L9.954 16H8.85ZM10.746 12.76H12.954L12.282 10.06C12.154 9.548 12.054 9.12 11.982 8.776C11.91 8.432 11.866 8.208 11.85 8.104C11.834 8.208 11.79 8.432 11.718 8.776C11.646 9.12 11.546 9.544 11.418 10.048L10.746 12.76Z" fill="var(--color-text)"></path></g><g id="icon-524288"><rect fill="var(--color-icon-background)" stroke="#FF4D4D" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="12"></rect><path d="M8.85 16L11.13 7.24H12.582L14.85 16H13.758L13.182 13.672H10.53L9.954 16H8.85ZM10.746 12.76H12.954L12.282 10.06C12.154 9.548 12.054 9.12 11.982 8.776C11.91 8.432 11.866 8.208 11.85 8.104C11.834 8.208 11.79 8.432 11.718 8.776C11.646 9.12 11.546 9.544 11.418 10.048L10.746 12.76Z" fill="var(--color-text)"></path></g><g id="icon-1048576"><rect fill="var(--color-icon-background)" stroke="#FF4D4D" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="12"></rect><path d="M8.85 16L11.13 7.24H12.582L14.85 16H13.758L13.182 13.672H10.53L9.954 16H8.85ZM10.746 12.76H12.954L12.282 10.06C12.154 9.548 12.054 9.12 11.982 8.776C11.91 8.432 11.866 8.208 11.85 8.104C11.834 8.208 11.79 8.432 11.718 8.776C11.646 9.12 11.546 9.544 11.418 10.048L10.746 12.76Z" fill="var(--color-text)"></path></g><g id="icon-2097152"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-type-alias)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><path d="M11.31 16V8.224H8.91V7.24H14.79V8.224H12.39V16H11.31Z" fill="var(--color-text)"></path></g><g id="icon-4194304"><rect fill="var(--color-icon-background)" stroke="#FF4D82" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="12"></rect><path d="M10.354 17V8.24H13.066C13.586 8.24 14.042 8.348 14.434 8.564C14.826 8.772 15.13 9.064 15.346 9.44C15.562 9.816 15.67 10.256 15.67 10.76C15.67 11.352 15.514 11.86 15.202 12.284C14.898 12.708 14.482 13 13.954 13.16L15.79 17H14.518L12.838 13.28H11.434V17H10.354ZM11.434 12.308H13.066C13.514 12.308 13.874 12.168 14.146 11.888C14.418 11.6 14.554 11.224 14.554 10.76C14.554 10.288 14.418 9.912 14.146 9.632C13.874 9.352 13.514 9.212 13.066 9.212H11.434V12.308Z" fill="var(--color-text)"></path></g><g id="icon-chevronDown"><path d="M4.93896 8.531L12 15.591L19.061 8.531L16.939 6.409L12 11.349L7.06098 6.409L4.93896 8.531Z" fill="var(--color-text)"></path></g><g id="icon-chevronSmall"><path d="M1.5 5.50969L8 11.6609L14.5 5.50969L12.5466 3.66086L8 7.96494L3.45341 3.66086L1.5 5.50969Z" fill="var(--color-text)"></path></g><g id="icon-checkbox"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></g><g id="icon-menu"><rect x="1" y="3" width="14" height="2" fill="var(--color-text)"></rect><rect x="1" y="7" width="14" height="2" fill="var(--color-text)"></rect><rect x="1" y="11" width="14" height="2" fill="var(--color-text)"></rect></g><g id="icon-search"><path d="M15.7824 13.833L12.6666 10.7177C12.5259 10.5771 12.3353 10.499 12.1353 10.499H11.6259C12.4884 9.39596 13.001 8.00859 13.001 6.49937C13.001 2.90909 10.0914 0 6.50048 0C2.90959 0 0 2.90909 0 6.49937C0 10.0896 2.90959 12.9987 6.50048 12.9987C8.00996 12.9987 9.39756 12.4863 10.5008 11.6239V12.1332C10.5008 12.3332 10.5789 12.5238 10.7195 12.6644L13.8354 15.7797C14.1292 16.0734 14.6042 16.0734 14.8948 15.7797L15.7793 14.8954C16.0731 14.6017 16.0731 14.1267 15.7824 13.833ZM6.50048 10.499C4.29094 10.499 2.50018 8.71165 2.50018 6.49937C2.50018 4.29021 4.28781 2.49976 6.50048 2.49976C8.71001 2.49976 10.5008 4.28708 10.5008 6.49937C10.5008 8.70852 8.71314 10.499 6.50048 10.499Z" fill="var(--color-text)"></path></g><g id="icon-anchor"><g stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></g></g></svg></body></html>
package/jest.config.js ADDED
@@ -0,0 +1,8 @@
1
+ module.exports = {
2
+ preset: 'ts-jest',
3
+ testEnvironment: 'node',
4
+ testMatch: ['<rootDir>/test/**/*.test.ts', '<rootDir>/test/**/*.test.js'],
5
+ collectCoverage: true,
6
+ coverageReporters: ['clover', 'json', 'lcov', ['text', {skipFull: true}], "json-summary"],
7
+ coverageDirectory: 'coverage'
8
+ };
package/package.json ADDED
@@ -0,0 +1,113 @@
1
+ {
2
+ "name": "tree-set-typed",
3
+ "version": "2.3.0",
4
+ "description": "TreeSet - A sorted set implementation based on Red-Black Tree",
5
+ "browser": "dist/umd/tree-set-typed.min.js",
6
+ "umd:main": "dist/umd/tree-set-typed.min.js",
7
+ "main": "dist/cjs/index.cjs",
8
+ "module": "dist/esm/index.mjs",
9
+ "types": "dist/types/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/types/index.d.ts",
13
+ "node": {
14
+ "import": "./dist/esm/index.mjs",
15
+ "require": "./dist/cjs/index.cjs"
16
+ },
17
+ "browser": {
18
+ "import": "./dist/esm-legacy/index.mjs",
19
+ "require": "./dist/cjs-legacy/index.cjs"
20
+ },
21
+ "import": "./dist/esm-legacy/index.mjs",
22
+ "require": "./dist/cjs-legacy/index.cjs"
23
+ },
24
+ "./modern": {
25
+ "types": "./dist/types/index.d.ts",
26
+ "import": "./dist/esm/index.mjs",
27
+ "require": "./dist/cjs/index.cjs"
28
+ },
29
+ "./legacy": {
30
+ "types": "./dist/types/index.d.ts",
31
+ "import": "./dist/esm-legacy/index.mjs",
32
+ "require": "./dist/cjs-legacy/index.cjs"
33
+ }
34
+ },
35
+ "sideEffects": false,
36
+ "engines": {
37
+ "node": ">=12.20.0",
38
+ "npm": ">=6.14.0"
39
+ },
40
+ "scripts": {
41
+ "build": "npm run build:ecu",
42
+ "build:node": "tsup --config tsup.node.config.js",
43
+ "build:types": "rm -rf dist/types && tsc -p tsconfig.types.json",
44
+ "build:umd": "tsup",
45
+ "build:ecu": "npm run build:node && npm run build:types && npm run build:umd",
46
+ "lint": "eslint --fix \"src/**/*.{js,ts}\"",
47
+ "format": "prettier --write \"src/**/*.{js,ts}\"",
48
+ "test": "jest",
49
+ "build:docs": "typedoc --out docs ./src",
50
+ "deps:check": "dependency-cruiser src",
51
+ "build:publish": "npm run build && npm publish"
52
+ },
53
+ "repository": {
54
+ "type": "git",
55
+ "url": "git+https://github.com/zrwusa/data-structure-typed.git"
56
+ },
57
+ "keywords": [
58
+ "tree set",
59
+ "treeset",
60
+ "tree-set",
61
+ "sorted set",
62
+ "sortedset",
63
+ "ordered set",
64
+ "orderedset",
65
+ "navigable set",
66
+ "red black tree",
67
+ "self-balancing",
68
+ "binary search tree",
69
+ "javascript",
70
+ "typescript",
71
+ "data structure",
72
+ "data-structure",
73
+ "sorted",
74
+ "ordering",
75
+ "unique",
76
+ "set",
77
+ "collection",
78
+ "Node.js",
79
+ "CommonJS",
80
+ "ES6",
81
+ "UMD",
82
+ "esmodule",
83
+ "java.util.TreeSet",
84
+ "c++ std::set",
85
+ "stl"
86
+ ],
87
+ "author": "Pablo Zeng zrwusa@gmail.com",
88
+ "license": "MIT",
89
+ "bugs": {
90
+ "url": "https://github.com/zrwusa/data-structure-typed/issues"
91
+ },
92
+ "homepage": "https://data-structure-typed-docs.vercel.app",
93
+ "devDependencies": {
94
+ "@types/jest": "^29.5.3",
95
+ "@types/node": "^20.4.9",
96
+ "@typescript-eslint/eslint-plugin": "^5.6.0",
97
+ "@typescript-eslint/parser": "^5.11.0",
98
+ "eslint": "^7.32.0",
99
+ "eslint-config-prettier": "^8.3.0",
100
+ "eslint-import-resolver-alias": "^1.1.2",
101
+ "eslint-import-resolver-typescript": "^2.5.0",
102
+ "eslint-plugin-import": "^2.25.4",
103
+ "jest": "^29.6.2",
104
+ "prettier": "^3.0.3",
105
+ "ts-jest": "^29.1.1",
106
+ "tsup": "^8.5.1",
107
+ "typedoc": "^0.25.1",
108
+ "typescript": "^4.9.5"
109
+ },
110
+ "dependencies": {
111
+ "data-structure-typed": "^2.3.0"
112
+ }
113
+ }
@@ -0,0 +1,23 @@
1
+ export enum DFSOperation {
2
+ VISIT = 0,
3
+ PROCESS = 1
4
+ }
5
+
6
+ export class Range<K> {
7
+ constructor(
8
+ public low: K,
9
+ public high: K,
10
+ public includeLow: boolean = true,
11
+ public includeHigh: boolean = true
12
+ ) {
13
+ // if (!(isComparable(low) && isComparable(high))) throw new RangeError('low or high is not comparable');
14
+ // if (low > high) throw new RangeError('low must be less than or equal to high');
15
+ }
16
+
17
+ // Determine whether a key is within the range
18
+ isInRange(key: K, comparator: (a: K, b: K) => number): boolean {
19
+ const lowCheck = this.includeLow ? comparator(key, this.low) >= 0 : comparator(key, this.low) > 0;
20
+ const highCheck = this.includeHigh ? comparator(key, this.high) <= 0 : comparator(key, this.high) < 0;
21
+ return lowCheck && highCheck;
22
+ }
23
+ }
@@ -0,0 +1,4 @@
1
+ export enum DFSOperation {
2
+ VISIT = 0,
3
+ PROCESS = 1
4
+ }
@@ -0,0 +1,2 @@
1
+ export * from './iterable-entry-base';
2
+ export * from './iterable-element-base';
@@ -0,0 +1,352 @@
1
+ import type { ElementCallback, IterableElementBaseOptions, ReduceElementCallback } from '../../types';
2
+
3
+ /**
4
+ * Base class that makes a data structure iterable and provides common
5
+ * element-wise utilities (e.g., map/filter/reduce/find).
6
+ *
7
+ * @template E The public element type yielded by the structure.
8
+ * @template R The underlying "raw" element type used internally or by converters.
9
+ *
10
+ * @remarks
11
+ * This class implements the JavaScript iteration protocol (via `Symbol.iterator`)
12
+ * and offers array-like helpers with predictable time/space complexity.
13
+ */
14
+ export abstract class IterableElementBase<E, R> implements Iterable<E> {
15
+ /**
16
+ * Create a new iterable base.
17
+ *
18
+ * @param options Optional behavior overrides. When provided, a `toElementFn`
19
+ * is used to convert a raw element (`R`) into a public element (`E`).
20
+ *
21
+ * @remarks
22
+ * Time O(1), Space O(1).
23
+ */
24
+ protected constructor(options?: IterableElementBaseOptions<E, R>) {
25
+ if (options) {
26
+ const { toElementFn } = options;
27
+ if (typeof toElementFn === 'function') this._toElementFn = toElementFn;
28
+ else if (toElementFn) throw new TypeError('toElementFn must be a function type');
29
+ }
30
+ }
31
+
32
+ /**
33
+ * The converter used to transform a raw element (`R`) into a public element (`E`).
34
+ *
35
+ * @remarks
36
+ * Time O(1), Space O(1).
37
+ */
38
+ protected _toElementFn?: (rawElement: R) => E;
39
+
40
+ /**
41
+ * Exposes the current `toElementFn`, if configured.
42
+ *
43
+ * @returns The converter function or `undefined` when not set.
44
+ * @remarks
45
+ * Time O(1), Space O(1).
46
+ */
47
+ get toElementFn(): ((rawElement: R) => E) | undefined {
48
+ return this._toElementFn;
49
+ }
50
+
51
+ /**
52
+ * Returns an iterator over the structure's elements.
53
+ *
54
+ * @param args Optional iterator arguments forwarded to the internal iterator.
55
+ * @returns An `IterableIterator<E>` that yields the elements in traversal order.
56
+ *
57
+ * @remarks
58
+ * Producing the iterator is O(1); consuming the entire iterator is Time O(n) with O(1) extra space.
59
+ */
60
+ *[Symbol.iterator](...args: unknown[]): IterableIterator<E> {
61
+ yield* this._getIterator(...args);
62
+ }
63
+
64
+ /**
65
+ * Returns an iterator over the values (alias of the default iterator).
66
+ *
67
+ * @returns An `IterableIterator<E>` over all elements.
68
+ * @remarks
69
+ * Creating the iterator is O(1); full iteration is Time O(n), Space O(1).
70
+ */
71
+ *values(): IterableIterator<E> {
72
+ for (const item of this) yield item;
73
+ }
74
+
75
+ /**
76
+ * Tests whether all elements satisfy the predicate.
77
+ *
78
+ * @template TReturn
79
+ * @param predicate Function invoked for each element with signature `(value, index, self)`.
80
+ * @param thisArg Optional `this` binding for the predicate.
81
+ * @returns `true` if every element passes; otherwise `false`.
82
+ *
83
+ * @remarks
84
+ * Time O(n) in the worst case; may exit early when the first failure is found. Space O(1).
85
+ */
86
+ every(predicate: ElementCallback<E, R, boolean>, thisArg?: unknown): boolean {
87
+ let index = 0;
88
+ for (const item of this) {
89
+ if (thisArg === undefined) {
90
+ if (!predicate(item, index++, this)) return false;
91
+ } else {
92
+ const fn = predicate as (this: unknown, v: E, i: number, self: this) => boolean;
93
+ if (!fn.call(thisArg, item, index++, this)) return false;
94
+ }
95
+ }
96
+ return true;
97
+ }
98
+
99
+ /**
100
+ * Tests whether at least one element satisfies the predicate.
101
+ *
102
+ * @param predicate Function invoked for each element with signature `(value, index, self)`.
103
+ * @param thisArg Optional `this` binding for the predicate.
104
+ * @returns `true` if any element passes; otherwise `false`.
105
+ *
106
+ * @remarks
107
+ * Time O(n) in the worst case; may exit early on first success. Space O(1).
108
+ */
109
+ some(predicate: ElementCallback<E, R, boolean>, thisArg?: unknown): boolean {
110
+ let index = 0;
111
+ for (const item of this) {
112
+ if (thisArg === undefined) {
113
+ if (predicate(item, index++, this)) return true;
114
+ } else {
115
+ const fn = predicate as (this: unknown, v: E, i: number, self: this) => boolean;
116
+ if (fn.call(thisArg, item, index++, this)) return true;
117
+ }
118
+ }
119
+ return false;
120
+ }
121
+
122
+ /**
123
+ * Invokes a callback for each element in iteration order.
124
+ *
125
+ * @param callbackfn Function invoked per element with signature `(value, index, self)`.
126
+ * @param thisArg Optional `this` binding for the callback.
127
+ * @returns `void`.
128
+ *
129
+ * @remarks
130
+ * Time O(n), Space O(1).
131
+ */
132
+ forEach(callbackfn: ElementCallback<E, R, void>, thisArg?: unknown): void {
133
+ let index = 0;
134
+ for (const item of this) {
135
+ if (thisArg === undefined) {
136
+ callbackfn(item, index++, this);
137
+ } else {
138
+ const fn = callbackfn as (this: unknown, v: E, i: number, self: this) => void;
139
+ fn.call(thisArg, item, index++, this);
140
+ }
141
+ }
142
+ }
143
+
144
+ /**
145
+ * Finds the first element that satisfies the predicate and returns it.
146
+ *
147
+ * @overload
148
+ * Finds the first element of type `S` (a subtype of `E`) that satisfies the predicate and returns it.
149
+ * @template S
150
+ * @param predicate Type-guard predicate: `(value, index, self) => value is S`.
151
+ * @param thisArg Optional `this` binding for the predicate.
152
+ * @returns The matched element typed as `S`, or `undefined` if not found.
153
+ *
154
+ * @overload
155
+ * @param predicate Boolean predicate: `(value, index, self) => boolean`.
156
+ * @param thisArg Optional `this` binding for the predicate.
157
+ * @returns The first matching element as `E`, or `undefined` if not found.
158
+ *
159
+ * @remarks
160
+ * Time O(n) in the worst case; may exit early on the first match. Space O(1).
161
+ */
162
+ find<S extends E>(predicate: ElementCallback<E, R, S>, thisArg?: unknown): S | undefined;
163
+ find(predicate: ElementCallback<E, R, unknown>, thisArg?: unknown): E | undefined;
164
+
165
+ // Implementation signature
166
+ find(predicate: ElementCallback<E, R, boolean>, thisArg?: unknown): E | undefined {
167
+ let index = 0;
168
+ for (const item of this) {
169
+ if (thisArg === undefined) {
170
+ if (predicate(item, index++, this)) return item;
171
+ } else {
172
+ const fn = predicate as (this: unknown, v: E, i: number, self: this) => boolean;
173
+ if (fn.call(thisArg, item, index++, this)) return item;
174
+ }
175
+ }
176
+ return;
177
+ }
178
+
179
+ /**
180
+ * Checks whether a strictly-equal element exists in the structure.
181
+ *
182
+ * @param element The element to test with `===` equality.
183
+ * @returns `true` if an equal element is found; otherwise `false`.
184
+ *
185
+ * @remarks
186
+ * Time O(n) in the worst case. Space O(1).
187
+ */
188
+ has(element: E): boolean {
189
+ for (const ele of this) if (ele === element) return true;
190
+ return false;
191
+ }
192
+
193
+ reduce(callbackfn: ReduceElementCallback<E, R>): E;
194
+ reduce(callbackfn: ReduceElementCallback<E, R>, initialValue: E): E;
195
+ reduce<U>(callbackfn: ReduceElementCallback<E, R, U>, initialValue: U): U;
196
+
197
+ /**
198
+ * Reduces all elements to a single accumulated value.
199
+ *
200
+ * @overload
201
+ * @param callbackfn Reducer of signature `(acc, value, index, self) => nextAcc`. The first element is used as the initial accumulator.
202
+ * @returns The final accumulated value typed as `E`.
203
+ *
204
+ * @overload
205
+ * @param callbackfn Reducer of signature `(acc, value, index, self) => nextAcc`.
206
+ * @param initialValue The initial accumulator value of type `E`.
207
+ * @returns The final accumulated value typed as `E`.
208
+ *
209
+ * @overload
210
+ * @template U The accumulator type when it differs from `E`.
211
+ * @param callbackfn Reducer of signature `(acc: U, value, index, self) => U`.
212
+ * @param initialValue The initial accumulator value of type `U`.
213
+ * @returns The final accumulated value typed as `U`.
214
+ *
215
+ * @remarks
216
+ * Time O(n), Space O(1). Throws if called on an empty structure without `initialValue`.
217
+ */
218
+ reduce<U>(callbackfn: ReduceElementCallback<E, R, U>, initialValue?: U): U {
219
+ let index = 0;
220
+ const iter = this[Symbol.iterator]();
221
+ let acc: U;
222
+
223
+ if (arguments.length >= 2) {
224
+ acc = initialValue as U;
225
+ } else {
226
+ const first = iter.next();
227
+ if (first.done) throw new TypeError('Reduce of empty structure with no initial value');
228
+ acc = first.value as unknown as U;
229
+ index = 1;
230
+ }
231
+
232
+ for (const value of iter as unknown as Iterable<E>) {
233
+ acc = callbackfn(acc, value, index++, this);
234
+ }
235
+ return acc;
236
+ }
237
+
238
+ /**
239
+ * Materializes the elements into a new array.
240
+ *
241
+ * @returns A shallow array copy of the iteration order.
242
+ * @remarks
243
+ * Time O(n), Space O(n).
244
+ */
245
+ toArray(): E[] {
246
+ return [...this];
247
+ }
248
+
249
+ /**
250
+ * Returns a representation of the structure suitable for quick visualization.
251
+ * Defaults to an array of elements; subclasses may override to provide richer visuals.
252
+ *
253
+ * @returns A visual representation (array by default).
254
+ * @remarks
255
+ * Time O(n), Space O(n).
256
+ */
257
+ toVisual(): E[] {
258
+ return [...this];
259
+ }
260
+
261
+ /**
262
+ * Prints `toVisual()` to the console. Intended for quick debugging.
263
+ *
264
+ * @returns `void`.
265
+ * @remarks
266
+ * Time O(n) due to materialization, Space O(n) for the intermediate representation.
267
+ */
268
+ print(): void {
269
+ console.log(this.toVisual());
270
+ }
271
+
272
+ /**
273
+ * Indicates whether the structure currently contains no elements.
274
+ *
275
+ * @returns `true` if empty; otherwise `false`.
276
+ * @remarks
277
+ * Expected Time O(1), Space O(1) for most implementations.
278
+ */
279
+ abstract isEmpty(): boolean;
280
+
281
+ /**
282
+ * Removes all elements from the structure.
283
+ *
284
+ * @returns `void`.
285
+ * @remarks
286
+ * Expected Time O(1) or O(n) depending on the implementation; Space O(1).
287
+ */
288
+ abstract clear(): void;
289
+
290
+ /**
291
+ * Creates a structural copy with the same element values and configuration.
292
+ *
293
+ * @returns A clone of the current instance (same concrete type).
294
+ * @remarks
295
+ * Expected Time O(n) to copy elements; Space O(n).
296
+ */
297
+ abstract clone(): this;
298
+
299
+ /**
300
+ * Maps each element to a new element and returns a new iterable structure.
301
+ *
302
+ * @template EM The mapped element type.
303
+ * @template RM The mapped raw element type used internally by the target structure.
304
+ * @param callback Function with signature `(value, index, self) => mapped`.
305
+ * @param options Optional options for the returned structure, including its `toElementFn`.
306
+ * @param thisArg Optional `this` binding for the callback.
307
+ * @returns A new `IterableElementBase<EM, RM>` containing mapped elements.
308
+ *
309
+ * @remarks
310
+ * Time O(n), Space O(n).
311
+ */
312
+ abstract map<EM, RM>(
313
+ callback: ElementCallback<E, R, EM>,
314
+ options?: IterableElementBaseOptions<EM, RM>,
315
+ thisArg?: unknown
316
+ ): IterableElementBase<EM, RM>;
317
+
318
+ /**
319
+ * Maps each element to the same element type and returns the same concrete structure type.
320
+ *
321
+ * @param callback Function with signature `(value, index, self) => mappedValue`.
322
+ * @param thisArg Optional `this` binding for the callback.
323
+ * @returns A new instance of the same concrete type with mapped elements.
324
+ *
325
+ * @remarks
326
+ * Time O(n), Space O(n).
327
+ */
328
+ abstract mapSame(callback: ElementCallback<E, R, E>, thisArg?: unknown): this;
329
+
330
+ /**
331
+ * Filters elements using the provided predicate and returns the same concrete structure type.
332
+ *
333
+ * @param predicate Function with signature `(value, index, self) => boolean`.
334
+ * @param thisArg Optional `this` binding for the predicate.
335
+ * @returns A new instance of the same concrete type containing only elements that pass the predicate.
336
+ *
337
+ * @remarks
338
+ * Time O(n), Space O(k) where `k` is the number of kept elements.
339
+ */
340
+ abstract filter(predicate: ElementCallback<E, R, boolean>, thisArg?: unknown): this;
341
+
342
+ /**
343
+ * Internal iterator factory used by the default iterator.
344
+ *
345
+ * @param args Optional iterator arguments.
346
+ * @returns An iterator over elements.
347
+ *
348
+ * @remarks
349
+ * Implementations should yield in O(1) per element with O(1) extra space when possible.
350
+ */
351
+ protected abstract _getIterator(...args: unknown[]): IterableIterator<E>;
352
+ }