data-structure-typed 1.50.2 → 1.50.4

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 (203) hide show
  1. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -13
  2. package/CHANGELOG.md +1 -1
  3. package/README.md +23 -21
  4. package/README_zh-CN.md +7 -7
  5. package/SPECIFICATION.md +56 -0
  6. package/SPONSOR-zh-CN.md +90 -0
  7. package/SPONSOR.md +54 -0
  8. package/benchmark/report.html +13 -13
  9. package/benchmark/report.json +149 -155
  10. package/dist/cjs/data-structures/base/iterable-base.d.ts +6 -0
  11. package/dist/cjs/data-structures/base/iterable-base.js.map +1 -1
  12. package/dist/cjs/data-structures/binary-tree/{tree-multimap.d.ts → avl-tree-multi-map.d.ts} +43 -10
  13. package/dist/cjs/data-structures/binary-tree/{tree-multimap.js → avl-tree-multi-map.js} +50 -12
  14. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js.map +1 -0
  15. package/dist/cjs/data-structures/binary-tree/avl-tree.d.ts +29 -1
  16. package/dist/cjs/data-structures/binary-tree/avl-tree.js +33 -1
  17. package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +1 -1
  18. package/dist/cjs/data-structures/binary-tree/binary-indexed-tree.d.ts +22 -0
  19. package/dist/cjs/data-structures/binary-tree/binary-indexed-tree.js +22 -0
  20. package/dist/cjs/data-structures/binary-tree/binary-indexed-tree.js.map +1 -1
  21. package/dist/cjs/data-structures/binary-tree/binary-tree.d.ts +1 -1
  22. package/dist/cjs/data-structures/binary-tree/binary-tree.js +1 -1
  23. package/dist/cjs/data-structures/binary-tree/bst.d.ts +46 -13
  24. package/dist/cjs/data-structures/binary-tree/bst.js +51 -20
  25. package/dist/cjs/data-structures/binary-tree/bst.js.map +1 -1
  26. package/dist/cjs/data-structures/binary-tree/index.d.ts +2 -1
  27. package/dist/cjs/data-structures/binary-tree/index.js +2 -1
  28. package/dist/cjs/data-structures/binary-tree/index.js.map +1 -1
  29. package/dist/cjs/data-structures/binary-tree/rb-tree.d.ts +54 -2
  30. package/dist/cjs/data-structures/binary-tree/rb-tree.js +90 -24
  31. package/dist/cjs/data-structures/binary-tree/rb-tree.js.map +1 -1
  32. package/dist/cjs/data-structures/binary-tree/segment-tree.d.ts +99 -6
  33. package/dist/cjs/data-structures/binary-tree/segment-tree.js +127 -10
  34. package/dist/cjs/data-structures/binary-tree/segment-tree.js.map +1 -1
  35. package/dist/cjs/data-structures/binary-tree/tree-multi-map.d.ts +200 -0
  36. package/dist/cjs/data-structures/binary-tree/tree-multi-map.js +400 -0
  37. package/dist/cjs/data-structures/binary-tree/tree-multi-map.js.map +1 -0
  38. package/dist/cjs/data-structures/graph/abstract-graph.d.ts +0 -78
  39. package/dist/cjs/data-structures/graph/abstract-graph.js +0 -189
  40. package/dist/cjs/data-structures/graph/abstract-graph.js.map +1 -1
  41. package/dist/cjs/data-structures/graph/directed-graph.d.ts +59 -0
  42. package/dist/cjs/data-structures/graph/directed-graph.js +105 -0
  43. package/dist/cjs/data-structures/graph/directed-graph.js.map +1 -1
  44. package/dist/cjs/data-structures/graph/undirected-graph.d.ts +60 -7
  45. package/dist/cjs/data-structures/graph/undirected-graph.js +126 -18
  46. package/dist/cjs/data-structures/graph/undirected-graph.js.map +1 -1
  47. package/dist/cjs/data-structures/hash/hash-map.d.ts +143 -23
  48. package/dist/cjs/data-structures/hash/hash-map.js +196 -62
  49. package/dist/cjs/data-structures/hash/hash-map.js.map +1 -1
  50. package/dist/cjs/data-structures/heap/heap.d.ts +29 -19
  51. package/dist/cjs/data-structures/heap/heap.js +29 -20
  52. package/dist/cjs/data-structures/heap/heap.js.map +1 -1
  53. package/dist/cjs/data-structures/linked-list/doubly-linked-list.d.ts +71 -25
  54. package/dist/cjs/data-structures/linked-list/doubly-linked-list.js +83 -25
  55. package/dist/cjs/data-structures/linked-list/doubly-linked-list.js.map +1 -1
  56. package/dist/cjs/data-structures/linked-list/singly-linked-list.d.ts +26 -3
  57. package/dist/cjs/data-structures/linked-list/singly-linked-list.js +34 -3
  58. package/dist/cjs/data-structures/linked-list/singly-linked-list.js.map +1 -1
  59. package/dist/cjs/data-structures/linked-list/skip-linked-list.d.ts +2 -2
  60. package/dist/cjs/data-structures/linked-list/skip-linked-list.js +2 -2
  61. package/dist/cjs/data-structures/matrix/matrix.d.ts +1 -1
  62. package/dist/cjs/data-structures/matrix/matrix.js +1 -1
  63. package/dist/cjs/data-structures/priority-queue/max-priority-queue.d.ts +10 -0
  64. package/dist/cjs/data-structures/priority-queue/max-priority-queue.js +10 -0
  65. package/dist/cjs/data-structures/priority-queue/max-priority-queue.js.map +1 -1
  66. package/dist/cjs/data-structures/priority-queue/min-priority-queue.d.ts +11 -0
  67. package/dist/cjs/data-structures/priority-queue/min-priority-queue.js +11 -0
  68. package/dist/cjs/data-structures/priority-queue/min-priority-queue.js.map +1 -1
  69. package/dist/cjs/data-structures/priority-queue/priority-queue.d.ts +8 -0
  70. package/dist/cjs/data-structures/priority-queue/priority-queue.js +8 -0
  71. package/dist/cjs/data-structures/priority-queue/priority-queue.js.map +1 -1
  72. package/dist/cjs/data-structures/queue/deque.d.ts +95 -21
  73. package/dist/cjs/data-structures/queue/deque.js +100 -16
  74. package/dist/cjs/data-structures/queue/deque.js.map +1 -1
  75. package/dist/cjs/data-structures/queue/queue.d.ts +65 -45
  76. package/dist/cjs/data-structures/queue/queue.js +65 -45
  77. package/dist/cjs/data-structures/queue/queue.js.map +1 -1
  78. package/dist/cjs/data-structures/stack/stack.d.ts +36 -22
  79. package/dist/cjs/data-structures/stack/stack.js +36 -22
  80. package/dist/cjs/data-structures/stack/stack.js.map +1 -1
  81. package/dist/cjs/data-structures/tree/tree.d.ts +57 -3
  82. package/dist/cjs/data-structures/tree/tree.js +77 -11
  83. package/dist/cjs/data-structures/tree/tree.js.map +1 -1
  84. package/dist/cjs/data-structures/trie/trie.d.ts +100 -36
  85. package/dist/cjs/data-structures/trie/trie.js +115 -36
  86. package/dist/cjs/data-structures/trie/trie.js.map +1 -1
  87. package/dist/cjs/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +5 -0
  88. package/dist/cjs/types/data-structures/binary-tree/avl-tree-multi-map.js +3 -0
  89. package/dist/cjs/types/data-structures/binary-tree/avl-tree-multi-map.js.map +1 -0
  90. package/dist/cjs/types/data-structures/binary-tree/index.d.ts +2 -1
  91. package/dist/cjs/types/data-structures/binary-tree/index.js +2 -1
  92. package/dist/cjs/types/data-structures/binary-tree/index.js.map +1 -1
  93. package/dist/cjs/types/data-structures/binary-tree/tree-multi-map.d.ts +5 -0
  94. package/dist/cjs/types/data-structures/binary-tree/{tree-multimap.js → tree-multi-map.js} +1 -1
  95. package/dist/cjs/types/data-structures/binary-tree/tree-multi-map.js.map +1 -0
  96. package/dist/mjs/data-structures/base/iterable-base.d.ts +6 -0
  97. package/dist/mjs/data-structures/binary-tree/{tree-multimap.d.ts → avl-tree-multi-map.d.ts} +43 -10
  98. package/dist/mjs/data-structures/binary-tree/{tree-multimap.js → avl-tree-multi-map.js} +46 -9
  99. package/dist/mjs/data-structures/binary-tree/avl-tree.d.ts +29 -1
  100. package/dist/mjs/data-structures/binary-tree/avl-tree.js +34 -2
  101. package/dist/mjs/data-structures/binary-tree/binary-indexed-tree.d.ts +22 -0
  102. package/dist/mjs/data-structures/binary-tree/binary-indexed-tree.js +22 -0
  103. package/dist/mjs/data-structures/binary-tree/binary-tree.d.ts +1 -1
  104. package/dist/mjs/data-structures/binary-tree/binary-tree.js +1 -1
  105. package/dist/mjs/data-structures/binary-tree/bst.d.ts +46 -13
  106. package/dist/mjs/data-structures/binary-tree/bst.js +51 -20
  107. package/dist/mjs/data-structures/binary-tree/index.d.ts +2 -1
  108. package/dist/mjs/data-structures/binary-tree/index.js +2 -1
  109. package/dist/mjs/data-structures/binary-tree/rb-tree.d.ts +54 -2
  110. package/dist/mjs/data-structures/binary-tree/rb-tree.js +91 -25
  111. package/dist/mjs/data-structures/binary-tree/segment-tree.d.ts +99 -6
  112. package/dist/mjs/data-structures/binary-tree/segment-tree.js +127 -10
  113. package/dist/mjs/data-structures/binary-tree/tree-multi-map.d.ts +200 -0
  114. package/dist/mjs/data-structures/binary-tree/tree-multi-map.js +397 -0
  115. package/dist/mjs/data-structures/graph/abstract-graph.d.ts +0 -78
  116. package/dist/mjs/data-structures/graph/abstract-graph.js +0 -188
  117. package/dist/mjs/data-structures/graph/directed-graph.d.ts +59 -0
  118. package/dist/mjs/data-structures/graph/directed-graph.js +105 -0
  119. package/dist/mjs/data-structures/graph/undirected-graph.d.ts +60 -7
  120. package/dist/mjs/data-structures/graph/undirected-graph.js +127 -19
  121. package/dist/mjs/data-structures/hash/hash-map.d.ts +143 -23
  122. package/dist/mjs/data-structures/hash/hash-map.js +204 -70
  123. package/dist/mjs/data-structures/heap/heap.d.ts +29 -19
  124. package/dist/mjs/data-structures/heap/heap.js +29 -20
  125. package/dist/mjs/data-structures/linked-list/doubly-linked-list.d.ts +71 -25
  126. package/dist/mjs/data-structures/linked-list/doubly-linked-list.js +86 -28
  127. package/dist/mjs/data-structures/linked-list/singly-linked-list.d.ts +26 -3
  128. package/dist/mjs/data-structures/linked-list/singly-linked-list.js +36 -5
  129. package/dist/mjs/data-structures/linked-list/skip-linked-list.d.ts +2 -2
  130. package/dist/mjs/data-structures/linked-list/skip-linked-list.js +2 -2
  131. package/dist/mjs/data-structures/matrix/matrix.d.ts +1 -1
  132. package/dist/mjs/data-structures/matrix/matrix.js +1 -1
  133. package/dist/mjs/data-structures/priority-queue/max-priority-queue.d.ts +10 -0
  134. package/dist/mjs/data-structures/priority-queue/max-priority-queue.js +10 -0
  135. package/dist/mjs/data-structures/priority-queue/min-priority-queue.d.ts +11 -0
  136. package/dist/mjs/data-structures/priority-queue/min-priority-queue.js +11 -0
  137. package/dist/mjs/data-structures/priority-queue/priority-queue.d.ts +8 -0
  138. package/dist/mjs/data-structures/priority-queue/priority-queue.js +8 -0
  139. package/dist/mjs/data-structures/queue/deque.d.ts +95 -21
  140. package/dist/mjs/data-structures/queue/deque.js +105 -21
  141. package/dist/mjs/data-structures/queue/queue.d.ts +65 -45
  142. package/dist/mjs/data-structures/queue/queue.js +65 -45
  143. package/dist/mjs/data-structures/stack/stack.d.ts +36 -22
  144. package/dist/mjs/data-structures/stack/stack.js +36 -22
  145. package/dist/mjs/data-structures/tree/tree.d.ts +57 -3
  146. package/dist/mjs/data-structures/tree/tree.js +80 -14
  147. package/dist/mjs/data-structures/trie/trie.d.ts +100 -36
  148. package/dist/mjs/data-structures/trie/trie.js +118 -39
  149. package/dist/mjs/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +5 -0
  150. package/dist/mjs/types/data-structures/binary-tree/index.d.ts +2 -1
  151. package/dist/mjs/types/data-structures/binary-tree/index.js +2 -1
  152. package/dist/mjs/types/data-structures/binary-tree/tree-multi-map.d.ts +5 -0
  153. package/dist/mjs/types/data-structures/binary-tree/tree-multi-map.js +1 -0
  154. package/dist/umd/data-structure-typed.js +1876 -656
  155. package/dist/umd/data-structure-typed.min.js +2 -2
  156. package/dist/umd/data-structure-typed.min.js.map +1 -1
  157. package/package.json +59 -58
  158. package/src/data-structures/base/iterable-base.ts +12 -0
  159. package/src/data-structures/binary-tree/{tree-multimap.ts → avl-tree-multi-map.ts} +59 -20
  160. package/src/data-structures/binary-tree/avl-tree.ts +37 -3
  161. package/src/data-structures/binary-tree/binary-indexed-tree.ts +22 -0
  162. package/src/data-structures/binary-tree/binary-tree.ts +1 -1
  163. package/src/data-structures/binary-tree/bst.ts +51 -19
  164. package/src/data-structures/binary-tree/index.ts +2 -1
  165. package/src/data-structures/binary-tree/rb-tree.ts +99 -28
  166. package/src/data-structures/binary-tree/segment-tree.ts +145 -11
  167. package/src/data-structures/binary-tree/tree-multi-map.ts +463 -0
  168. package/src/data-structures/graph/abstract-graph.ts +0 -211
  169. package/src/data-structures/graph/directed-graph.ts +122 -0
  170. package/src/data-structures/graph/undirected-graph.ts +143 -19
  171. package/src/data-structures/hash/hash-map.ts +228 -76
  172. package/src/data-structures/heap/heap.ts +31 -20
  173. package/src/data-structures/linked-list/doubly-linked-list.ts +96 -29
  174. package/src/data-structures/linked-list/singly-linked-list.ts +42 -6
  175. package/src/data-structures/linked-list/skip-linked-list.ts +2 -2
  176. package/src/data-structures/matrix/matrix.ts +1 -1
  177. package/src/data-structures/priority-queue/max-priority-queue.ts +10 -0
  178. package/src/data-structures/priority-queue/min-priority-queue.ts +11 -0
  179. package/src/data-structures/priority-queue/priority-queue.ts +8 -0
  180. package/src/data-structures/queue/deque.ts +118 -22
  181. package/src/data-structures/queue/queue.ts +68 -45
  182. package/src/data-structures/stack/stack.ts +39 -23
  183. package/src/data-structures/tree/tree.ts +89 -15
  184. package/src/data-structures/trie/trie.ts +131 -40
  185. package/src/types/data-structures/binary-tree/avl-tree-multi-map.ts +8 -0
  186. package/src/types/data-structures/binary-tree/index.ts +2 -1
  187. package/src/types/data-structures/binary-tree/tree-multi-map.ts +8 -0
  188. package/test/integration/index.html +2 -2
  189. package/test/performance/data-structures/graph/directed-graph.test.ts +1 -1
  190. package/test/unit/data-structures/binary-tree/{tree-multimap.test.ts → avl-tree-multi-map.test.ts} +55 -55
  191. package/test/unit/data-structures/binary-tree/overall.test.ts +24 -25
  192. package/test/unit/data-structures/binary-tree/tree-multi-map.test.ts +706 -0
  193. package/test/unit/data-structures/graph/abstract-graph.test.ts +3 -0
  194. package/test/unit/data-structures/graph/directed-graph.test.ts +189 -253
  195. package/test/unit/data-structures/graph/undirected-graph.test.ts +263 -18
  196. package/test/unit/data-structures/queue/queue.test.ts +2 -0
  197. package/test/unit/unrestricted-interconversion.test.ts +3 -3
  198. package/dist/cjs/data-structures/binary-tree/tree-multimap.js.map +0 -1
  199. package/dist/cjs/types/data-structures/binary-tree/tree-multimap.d.ts +0 -5
  200. package/dist/cjs/types/data-structures/binary-tree/tree-multimap.js.map +0 -1
  201. package/dist/mjs/types/data-structures/binary-tree/tree-multimap.d.ts +0 -5
  202. package/src/types/data-structures/binary-tree/tree-multimap.ts +0 -8
  203. /package/dist/mjs/types/data-structures/binary-tree/{tree-multimap.js → avl-tree-multi-map.js} +0 -0
@@ -102,6 +102,8 @@ var dataStructureTyped = (() => {
102
102
  var src_exports = {};
103
103
  __export(src_exports, {
104
104
  AVLTree: () => AVLTree,
105
+ AVLTreeMultiMap: () => AVLTreeMultiMap,
106
+ AVLTreeMultiMapNode: () => AVLTreeMultiMapNode,
105
107
  AVLTreeNode: () => AVLTreeNode,
106
108
  AbstractEdge: () => AbstractEdge,
107
109
  AbstractGraph: () => AbstractGraph,
@@ -152,8 +154,8 @@ var dataStructureTyped = (() => {
152
154
  SkipListNode: () => SkipListNode,
153
155
  Stack: () => Stack,
154
156
  THUNK_SYMBOL: () => THUNK_SYMBOL,
155
- TreeMultimap: () => TreeMultimap,
156
- TreeMultimapNode: () => TreeMultimapNode,
157
+ TreeMultiMap: () => TreeMultiMap,
158
+ TreeMultiMapNode: () => TreeMultiMapNode,
157
159
  TreeNode: () => TreeNode,
158
160
  Trie: () => Trie,
159
161
  TrieNode: () => TrieNode,
@@ -755,6 +757,22 @@ var dataStructureTyped = (() => {
755
757
  this.setMany(rawCollection);
756
758
  }
757
759
  }
760
+ /**
761
+ * The function returns the store object, which is a dictionary of HashMapStoreItem objects.
762
+ * @returns The store property is being returned. It is a dictionary-like object with string keys and
763
+ * values of type HashMapStoreItem<K, V>.
764
+ */
765
+ get store() {
766
+ return this._store;
767
+ }
768
+ /**
769
+ * The function returns the object map.
770
+ * @returns The `objMap` property is being returned, which is a `Map` object with keys of type
771
+ * `object` and values of type `V`.
772
+ */
773
+ get objMap() {
774
+ return this._objMap;
775
+ }
758
776
  /**
759
777
  * The function returns the value of the _toEntryFn property.
760
778
  * @returns The function being returned is `this._toEntryFn`.
@@ -762,22 +780,22 @@ var dataStructureTyped = (() => {
762
780
  get toEntryFn() {
763
781
  return this._toEntryFn;
764
782
  }
783
+ /**
784
+ * The function returns the size of an object.
785
+ * @returns The size of the object, which is a number.
786
+ */
787
+ get size() {
788
+ return this._size;
789
+ }
765
790
  /**
766
791
  * The hasFn function is a function that takes in an item and returns a boolean
767
792
  * indicating whether the item is contained within the hash table.
768
793
  *
769
794
  * @return The hash function
770
795
  */
771
- get hasFn() {
796
+ get hashFn() {
772
797
  return this._hashFn;
773
798
  }
774
- /**
775
- * The function returns the size of an object.
776
- * @returns The size of the object, which is a number.
777
- */
778
- get size() {
779
- return this._size;
780
- }
781
799
  /**
782
800
  * The function checks if a given element is an array with exactly two elements.
783
801
  * @param {any} rawElement - The `rawElement` parameter is of type `any`, which means it can be any
@@ -814,13 +832,13 @@ var dataStructureTyped = (() => {
814
832
  */
815
833
  set(key, value) {
816
834
  if (this._isObjKey(key)) {
817
- if (!this._objMap.has(key)) {
835
+ if (!this.objMap.has(key)) {
818
836
  this._size++;
819
837
  }
820
- this._objMap.set(key, value);
838
+ this.objMap.set(key, value);
821
839
  } else {
822
840
  const strKey = this._getNoObjKey(key);
823
- if (this._store[strKey] === void 0) {
841
+ if (this.store[strKey] === void 0) {
824
842
  this._size++;
825
843
  }
826
844
  this._store[strKey] = { key, value };
@@ -861,7 +879,7 @@ var dataStructureTyped = (() => {
861
879
  get(key) {
862
880
  var _a;
863
881
  if (this._isObjKey(key)) {
864
- return this._objMap.get(key);
882
+ return this.objMap.get(key);
865
883
  } else {
866
884
  const strKey = this._getNoObjKey(key);
867
885
  return (_a = this._store[strKey]) == null ? void 0 : _a.value;
@@ -875,10 +893,10 @@ var dataStructureTyped = (() => {
875
893
  */
876
894
  has(key) {
877
895
  if (this._isObjKey(key)) {
878
- return this._objMap.has(key);
896
+ return this.objMap.has(key);
879
897
  } else {
880
898
  const strKey = this._getNoObjKey(key);
881
- return strKey in this._store;
899
+ return strKey in this.store;
882
900
  }
883
901
  }
884
902
  /**
@@ -890,20 +908,24 @@ var dataStructureTyped = (() => {
890
908
  */
891
909
  delete(key) {
892
910
  if (this._isObjKey(key)) {
893
- if (this._objMap.has(key)) {
911
+ if (this.objMap.has(key)) {
894
912
  this._size--;
895
913
  }
896
- return this._objMap.delete(key);
914
+ return this.objMap.delete(key);
897
915
  } else {
898
916
  const strKey = this._getNoObjKey(key);
899
- if (strKey in this._store) {
900
- delete this._store[strKey];
917
+ if (strKey in this.store) {
918
+ delete this.store[strKey];
901
919
  this._size--;
902
920
  return true;
903
921
  }
904
922
  return false;
905
923
  }
906
924
  }
925
+ /**
926
+ * Time Complexity: O(n)
927
+ * Space Complexity: O(n)
928
+ */
907
929
  /**
908
930
  * The clone function creates a new HashMap with the same key-value pairs as
909
931
  * this one. The clone function is useful for creating a copy of an existing
@@ -912,7 +934,7 @@ var dataStructureTyped = (() => {
912
934
  * @return A new hashmap with the same values as this one
913
935
  */
914
936
  clone() {
915
- return new _HashMap(this, { hashFn: this._hashFn, toEntryFn: this.toEntryFn });
937
+ return new _HashMap(this, { hashFn: this.hashFn, toEntryFn: this.toEntryFn });
916
938
  }
917
939
  /**
918
940
  * Time Complexity: O(n)
@@ -940,10 +962,6 @@ var dataStructureTyped = (() => {
940
962
  }
941
963
  return resultMap;
942
964
  }
943
- /**
944
- * Time Complexity: O(n)
945
- * Space Complexity: O(n)
946
- */
947
965
  /**
948
966
  * Time Complexity: O(n)
949
967
  * Space Complexity: O(n)
@@ -986,22 +1004,34 @@ var dataStructureTyped = (() => {
986
1004
  * object map.
987
1005
  */
988
1006
  *_getIterator() {
989
- for (const node of Object.values(this._store)) {
1007
+ for (const node of Object.values(this.store)) {
990
1008
  yield [node.key, node.value];
991
1009
  }
992
- for (const node of this._objMap) {
1010
+ for (const node of this.objMap) {
993
1011
  yield node;
994
1012
  }
995
1013
  }
1014
+ /**
1015
+ * The function checks if a given key is an object or a function.
1016
+ * @param {any} key - The parameter "key" can be of any type.
1017
+ * @returns a boolean value.
1018
+ */
996
1019
  _isObjKey(key) {
997
1020
  const keyType = typeof key;
998
1021
  return (keyType === "object" || keyType === "function") && key !== null;
999
1022
  }
1023
+ /**
1024
+ * The function `_getNoObjKey` takes a key and returns a string representation of the key, handling
1025
+ * different types of keys.
1026
+ * @param {K} key - The `key` parameter is of type `K`, which represents the type of the key being
1027
+ * passed to the `_getNoObjKey` function.
1028
+ * @returns a string value.
1029
+ */
1000
1030
  _getNoObjKey(key) {
1001
1031
  const keyType = typeof key;
1002
1032
  let strKey;
1003
1033
  if (keyType !== "string" && keyType !== "number" && keyType !== "symbol") {
1004
- strKey = this._hashFn(key);
1034
+ strKey = this.hashFn(key);
1005
1035
  } else {
1006
1036
  if (keyType === "number") {
1007
1037
  strKey = key;
@@ -1024,11 +1054,13 @@ var dataStructureTyped = (() => {
1024
1054
  */
1025
1055
  constructor(rawCollection = [], options) {
1026
1056
  super();
1057
+ __publicField(this, "_sentinel");
1058
+ __publicField(this, "_hashFn", (key) => String(key));
1059
+ __publicField(this, "_objHashFn", (key) => key);
1027
1060
  __publicField(this, "_noObjMap", {});
1028
1061
  __publicField(this, "_objMap", /* @__PURE__ */ new WeakMap());
1029
1062
  __publicField(this, "_head");
1030
1063
  __publicField(this, "_tail");
1031
- __publicField(this, "_sentinel");
1032
1064
  __publicField(this, "_toEntryFn", (rawElement) => {
1033
1065
  if (this.isEntry(rawElement)) {
1034
1066
  return rawElement;
@@ -1039,8 +1071,6 @@ var dataStructureTyped = (() => {
1039
1071
  }
1040
1072
  });
1041
1073
  __publicField(this, "_size", 0);
1042
- __publicField(this, "_hashFn", (key) => String(key));
1043
- __publicField(this, "_objHashFn", (key) => key);
1044
1074
  this._sentinel = {};
1045
1075
  this._sentinel.prev = this._sentinel.next = this._head = this._tail = this._sentinel;
1046
1076
  if (options) {
@@ -1060,6 +1090,51 @@ var dataStructureTyped = (() => {
1060
1090
  }
1061
1091
  }
1062
1092
  }
1093
+ /**
1094
+ * The function returns the hash function used for generating a hash value for a given key.
1095
+ * @returns The hash function that takes a key of type K and returns a string.
1096
+ */
1097
+ get hashFn() {
1098
+ return this._hashFn;
1099
+ }
1100
+ /**
1101
+ * The function returns the object hash function.
1102
+ * @returns The function `objHashFn` is being returned.
1103
+ */
1104
+ get objHashFn() {
1105
+ return this._objHashFn;
1106
+ }
1107
+ /**
1108
+ * The function returns a record of HashMapLinkedNode objects with string keys.
1109
+ * @returns The method is returning a Record object, which is a TypeScript type that represents an
1110
+ * object with string keys and values that are HashMapLinkedNode objects with keys of type K and
1111
+ * values of type V or undefined.
1112
+ */
1113
+ get noObjMap() {
1114
+ return this._noObjMap;
1115
+ }
1116
+ /**
1117
+ * The function returns the WeakMap object used to map objects to HashMapLinkedNode instances.
1118
+ * @returns The `objMap` property is being returned.
1119
+ */
1120
+ get objMap() {
1121
+ return this._objMap;
1122
+ }
1123
+ /**
1124
+ * The function returns the head node of a HashMapLinkedNode.
1125
+ * @returns The method `getHead()` is returning a `HashMapLinkedNode` object with key type `K` and
1126
+ * value type `V | undefined`.
1127
+ */
1128
+ get head() {
1129
+ return this._head;
1130
+ }
1131
+ /**
1132
+ * The function returns the tail node of a HashMapLinkedNode.
1133
+ * @returns The `_tail` property of type `HashMapLinkedNode<K, V | undefined>` is being returned.
1134
+ */
1135
+ get tail() {
1136
+ return this._tail;
1137
+ }
1063
1138
  /**
1064
1139
  * The function returns the value of the _toEntryFn property.
1065
1140
  * @returns The function being returned is `this._toEntryFn`.
@@ -1074,6 +1149,10 @@ var dataStructureTyped = (() => {
1074
1149
  get size() {
1075
1150
  return this._size;
1076
1151
  }
1152
+ /**
1153
+ * Time Complexity: O(1)
1154
+ * Space Complexity: O(1)
1155
+ */
1077
1156
  /**
1078
1157
  * Time Complexity: O(1)
1079
1158
  * Space Complexity: O(1)
@@ -1085,8 +1164,12 @@ var dataStructureTyped = (() => {
1085
1164
  get first() {
1086
1165
  if (this._size === 0)
1087
1166
  return;
1088
- return [this._head.key, this._head.value];
1167
+ return [this.head.key, this.head.value];
1089
1168
  }
1169
+ /**
1170
+ * Time Complexity: O(1)
1171
+ * Space Complexity: O(1)
1172
+ */
1090
1173
  /**
1091
1174
  * Time Complexity: O(1)
1092
1175
  * Space Complexity: O(1)
@@ -1098,13 +1181,13 @@ var dataStructureTyped = (() => {
1098
1181
  get last() {
1099
1182
  if (this._size === 0)
1100
1183
  return;
1101
- return [this._tail.key, this._tail.value];
1184
+ return [this.tail.key, this.tail.value];
1102
1185
  }
1103
1186
  /**
1104
1187
  * The `begin()` function in TypeScript iterates over a linked list and yields key-value pairs.
1105
1188
  */
1106
1189
  *begin() {
1107
- let node = this._head;
1190
+ let node = this.head;
1108
1191
  while (node !== this._sentinel) {
1109
1192
  yield [node.key, node.value];
1110
1193
  node = node.next;
@@ -1115,12 +1198,16 @@ var dataStructureTyped = (() => {
1115
1198
  * key and value.
1116
1199
  */
1117
1200
  *reverseBegin() {
1118
- let node = this._tail;
1201
+ let node = this.tail;
1119
1202
  while (node !== this._sentinel) {
1120
1203
  yield [node.key, node.value];
1121
1204
  node = node.prev;
1122
1205
  }
1123
1206
  }
1207
+ /**
1208
+ * Time Complexity: O(1)
1209
+ * Space Complexity: O(1)
1210
+ */
1124
1211
  /**
1125
1212
  * Time Complexity: O(1)
1126
1213
  * Space Complexity: O(1)
@@ -1137,19 +1224,19 @@ var dataStructureTyped = (() => {
1137
1224
  let node;
1138
1225
  const isNewKey = !this.has(key);
1139
1226
  if (isWeakKey(key)) {
1140
- const hash = this._objHashFn(key);
1141
- node = this._objMap.get(hash);
1227
+ const hash = this.objHashFn(key);
1228
+ node = this.objMap.get(hash);
1142
1229
  if (!node && isNewKey) {
1143
- node = { key: hash, value, prev: this._tail, next: this._sentinel };
1144
- this._objMap.set(hash, node);
1230
+ node = { key: hash, value, prev: this.tail, next: this._sentinel };
1231
+ this.objMap.set(hash, node);
1145
1232
  } else if (node) {
1146
1233
  node.value = value;
1147
1234
  }
1148
1235
  } else {
1149
- const hash = this._hashFn(key);
1150
- node = this._noObjMap[hash];
1236
+ const hash = this.hashFn(key);
1237
+ node = this.noObjMap[hash];
1151
1238
  if (!node && isNewKey) {
1152
- this._noObjMap[hash] = node = { key, value, prev: this._tail, next: this._sentinel };
1239
+ this.noObjMap[hash] = node = { key, value, prev: this.tail, next: this._sentinel };
1153
1240
  } else if (node) {
1154
1241
  node.value = value;
1155
1242
  }
@@ -1159,8 +1246,8 @@ var dataStructureTyped = (() => {
1159
1246
  this._head = node;
1160
1247
  this._sentinel.next = node;
1161
1248
  } else {
1162
- this._tail.next = node;
1163
- node.prev = this._tail;
1249
+ this.tail.next = node;
1250
+ node.prev = this.tail;
1164
1251
  }
1165
1252
  this._tail = node;
1166
1253
  this._sentinel.prev = node;
@@ -1192,13 +1279,17 @@ var dataStructureTyped = (() => {
1192
1279
  */
1193
1280
  has(key) {
1194
1281
  if (isWeakKey(key)) {
1195
- const hash = this._objHashFn(key);
1196
- return this._objMap.has(hash);
1282
+ const hash = this.objHashFn(key);
1283
+ return this.objMap.has(hash);
1197
1284
  } else {
1198
- const hash = this._hashFn(key);
1199
- return hash in this._noObjMap;
1285
+ const hash = this.hashFn(key);
1286
+ return hash in this.noObjMap;
1200
1287
  }
1201
1288
  }
1289
+ /**
1290
+ * Time Complexity: O(1)
1291
+ * Space Complexity: O(1)
1292
+ */
1202
1293
  /**
1203
1294
  * Time Complexity: O(1)
1204
1295
  * Space Complexity: O(1)
@@ -1214,89 +1305,109 @@ var dataStructureTyped = (() => {
1214
1305
  */
1215
1306
  get(key) {
1216
1307
  if (isWeakKey(key)) {
1217
- const hash = this._objHashFn(key);
1218
- const node = this._objMap.get(hash);
1308
+ const hash = this.objHashFn(key);
1309
+ const node = this.objMap.get(hash);
1219
1310
  return node ? node.value : void 0;
1220
1311
  } else {
1221
- const hash = this._hashFn(key);
1222
- const node = this._noObjMap[hash];
1312
+ const hash = this.hashFn(key);
1313
+ const node = this.noObjMap[hash];
1223
1314
  return node ? node.value : void 0;
1224
1315
  }
1225
1316
  }
1226
1317
  /**
1227
- * Time Complexity: O(n), where n is the index.
1228
- * Space Complexity: O(1)
1229
- *
1230
- * The function `at` retrieves the key-value pair at a specified index in a linked list.
1231
- * @param {number} index - The index parameter is a number that represents the position of the
1232
- * element we want to retrieve from the data structure.
1233
- * @returns The method `at(index: number)` is returning an array containing the key-value pair at
1234
- * the specified index in the data structure. The key-value pair is represented as a tuple `[K, V]`,
1235
- * where `K` is the key and `V` is the value.
1236
- */
1318
+ * Time Complexity: O(n)
1319
+ * Space Complexity: O(1)
1320
+ * /
1321
+
1322
+ /**
1323
+ * Time Complexity: O(n)
1324
+ * Space Complexity: O(1)
1325
+ *
1326
+ * The function `at` retrieves the key-value pair at a specified index in a linked list.
1327
+ * @param {number} index - The index parameter is a number that represents the position of the
1328
+ * element we want to retrieve from the data structure.
1329
+ * @returns The method `at(index: number)` is returning an array containing the key-value pair at
1330
+ * the specified index in the data structure. The key-value pair is represented as a tuple `[K, V]`,
1331
+ * where `K` is the key and `V` is the value.
1332
+ */
1237
1333
  at(index) {
1238
1334
  rangeCheck(index, 0, this._size - 1);
1239
- let node = this._head;
1335
+ let node = this.head;
1240
1336
  while (index--) {
1241
1337
  node = node.next;
1242
1338
  }
1243
1339
  return node.value;
1244
1340
  }
1245
1341
  /**
1246
- * Time Complexity: O(1)
1247
- * Space Complexity: O(1)
1248
- *
1249
- * The `delete` function removes a key-value pair from a map-like data structure.
1250
- * @param {K} key - The `key` parameter is the key that you want to delete from the data structure.
1251
- * It can be of any type, but typically it is a string or an object.
1252
- * @returns a boolean value. It returns `true` if the deletion was successful, and `false` if the key
1253
- * was not found.
1254
- */
1342
+ * Time Complexity: O(1)
1343
+ * Space Complexity: O(1)
1344
+ * /
1345
+
1346
+ /**
1347
+ * Time Complexity: O(1)
1348
+ * Space Complexity: O(1)
1349
+ *
1350
+ * The `delete` function removes a key-value pair from a map-like data structure.
1351
+ * @param {K} key - The `key` parameter is the key that you want to delete from the data structure.
1352
+ * It can be of any type, but typically it is a string or an object.
1353
+ * @returns a boolean value. It returns `true` if the deletion was successful, and `false` if the key
1354
+ * was not found.
1355
+ */
1255
1356
  delete(key) {
1256
1357
  let node;
1257
1358
  if (isWeakKey(key)) {
1258
- const hash = this._objHashFn(key);
1259
- node = this._objMap.get(hash);
1359
+ const hash = this.objHashFn(key);
1360
+ node = this.objMap.get(hash);
1260
1361
  if (!node) {
1261
1362
  return false;
1262
1363
  }
1263
- this._objMap.delete(hash);
1364
+ this.objMap.delete(hash);
1264
1365
  } else {
1265
- const hash = this._hashFn(key);
1266
- node = this._noObjMap[hash];
1366
+ const hash = this.hashFn(key);
1367
+ node = this.noObjMap[hash];
1267
1368
  if (!node) {
1268
1369
  return false;
1269
1370
  }
1270
- delete this._noObjMap[hash];
1371
+ delete this.noObjMap[hash];
1271
1372
  }
1272
1373
  this._deleteNode(node);
1273
1374
  return true;
1274
1375
  }
1275
1376
  /**
1276
- * Time Complexity: O(n)
1277
- * Space Complexity: O(1)
1278
- *
1279
- * The `deleteAt` function deletes a node at a specified index in a linked list.
1280
- * @param {number} index - The index parameter represents the position at which the node should be
1281
- * deleted in the linked list.
1282
- * @returns The size of the list after deleting the element at the specified index.
1283
- */
1377
+ * Time Complexity: O(n)
1378
+ * Space Complexity: O(1)
1379
+ * /
1380
+
1381
+ /**
1382
+ * Time Complexity: O(n)
1383
+ * Space Complexity: O(1)
1384
+ *
1385
+ * The `deleteAt` function deletes a node at a specified index in a linked list.
1386
+ * @param {number} index - The index parameter represents the position at which the node should be
1387
+ * deleted in the linked list.
1388
+ * @returns The size of the list after deleting the element at the specified index.
1389
+ */
1284
1390
  deleteAt(index) {
1285
1391
  rangeCheck(index, 0, this._size - 1);
1286
- let node = this._head;
1392
+ let node = this.head;
1287
1393
  while (index--) {
1288
1394
  node = node.next;
1289
1395
  }
1290
1396
  return this._deleteNode(node);
1291
1397
  }
1292
1398
  /**
1293
- * Time Complexity: O(1)
1294
- * Space Complexity: O(1)
1295
- *
1296
- * The function checks if a data structure is empty by comparing its size to zero.
1297
- * @returns The method is returning a boolean value indicating whether the size of the object is 0 or
1298
- * not.
1299
- */
1399
+ * Time Complexity: O(1)
1400
+ * Space Complexity: O(1)
1401
+ * /
1402
+
1403
+ /**
1404
+ * Time Complexity: O(1)
1405
+ * Space Complexity: O(1)
1406
+ *
1407
+ * The function checks if a data structure is empty by comparing its size to zero.
1408
+ * @returns The method is returning a boolean value indicating whether the size of the object is 0 or
1409
+ * not.
1410
+ */
1300
1411
  isEmpty() {
1301
1412
  return this._size === 0;
1302
1413
  }
@@ -1310,11 +1421,16 @@ var dataStructureTyped = (() => {
1310
1421
  return Array.isArray(rawElement) && rawElement.length === 2;
1311
1422
  }
1312
1423
  /**
1313
- * Time Complexity: O(1)
1314
- * Space Complexity: O(1)
1315
- *
1316
- * The `clear` function clears all the entries in a data structure and resets its properties.
1317
- */
1424
+ * Time Complexity: O(1)
1425
+ * Space Complexity: O(1)
1426
+ * /
1427
+
1428
+ /**
1429
+ * Time Complexity: O(1)
1430
+ * Space Complexity: O(1)
1431
+ *
1432
+ * The `clear` function clears all the entries in a data structure and resets its properties.
1433
+ */
1318
1434
  clear() {
1319
1435
  this._noObjMap = {};
1320
1436
  this._size = 0;
@@ -1334,7 +1450,7 @@ var dataStructureTyped = (() => {
1334
1450
  * of the original `LinkedHashMap` object.
1335
1451
  */
1336
1452
  clone() {
1337
- const cloned = new _LinkedHashMap([], { hashFn: this._hashFn, objHashFn: this._objHashFn });
1453
+ const cloned = new _LinkedHashMap([], { hashFn: this.hashFn, objHashFn: this.objHashFn });
1338
1454
  for (const entry of this) {
1339
1455
  const [key, value] = entry;
1340
1456
  cloned.set(key, value);
@@ -1342,20 +1458,25 @@ var dataStructureTyped = (() => {
1342
1458
  return cloned;
1343
1459
  }
1344
1460
  /**
1345
- * Time Complexity: O(n)
1346
- * Space Complexity: O(n)
1347
- *
1348
- * The `filter` function creates a new `LinkedHashMap` containing key-value pairs from the original
1349
- * map that satisfy a given predicate function.
1350
- * @param predicate - The `predicate` parameter is a callback function that takes four arguments:
1351
- * `value`, `key`, `index`, and `this`. It should return a boolean value indicating whether the
1352
- * current element should be included in the filtered map or not.
1353
- * @param {any} [thisArg] - The `thisArg` parameter is an optional argument that allows you to
1354
- * specify the value of `this` within the `predicate` function. It is used when you want to bind a
1355
- * specific object as the context for the `predicate` function. If `thisArg` is not provided, `this
1356
- * @returns a new `LinkedHashMap` object that contains the key-value pairs from the original
1357
- * `LinkedHashMap` object that satisfy the given predicate function.
1358
- */
1461
+ * Time Complexity: O(n)
1462
+ * Space Complexity: O(n)
1463
+ * /
1464
+
1465
+ /**
1466
+ * Time Complexity: O(n)
1467
+ * Space Complexity: O(n)
1468
+ *
1469
+ * The `filter` function creates a new `LinkedHashMap` containing key-value pairs from the original
1470
+ * map that satisfy a given predicate function.
1471
+ * @param predicate - The `predicate` parameter is a callback function that takes four arguments:
1472
+ * `value`, `key`, `index`, and `this`. It should return a boolean value indicating whether the
1473
+ * current element should be included in the filtered map or not.
1474
+ * @param {any} [thisArg] - The `thisArg` parameter is an optional argument that allows you to
1475
+ * specify the value of `this` within the `predicate` function. It is used when you want to bind a
1476
+ * specific object as the context for the `predicate` function. If `thisArg` is not provided, `this
1477
+ * @returns a new `LinkedHashMap` object that contains the key-value pairs from the original
1478
+ * `LinkedHashMap` object that satisfy the given predicate function.
1479
+ */
1359
1480
  filter(predicate, thisArg) {
1360
1481
  const filteredMap = new _LinkedHashMap();
1361
1482
  let index = 0;
@@ -1368,22 +1489,27 @@ var dataStructureTyped = (() => {
1368
1489
  return filteredMap;
1369
1490
  }
1370
1491
  /**
1371
- * Time Complexity: O(n)
1372
- * Space Complexity: O(n)
1373
- *
1374
- * The `map` function in TypeScript creates a new `LinkedHashMap` by applying a callback function to
1375
- * each key-value pair in the original map.
1376
- * @param callback - The callback parameter is a function that will be called for each key-value pair
1377
- * in the map. It takes four arguments: the value of the current key-value pair, the key of the
1378
- * current key-value pair, the index of the current key-value pair, and the map itself. The callback
1379
- * function should
1380
- * @param {any} [thisArg] - The `thisArg` parameter is an optional argument that allows you to
1381
- * specify the value of `this` within the callback function. If provided, the callback function will
1382
- * be called with `thisArg` as its `this` value. If not provided, `this` will refer to the current
1383
- * map
1384
- * @returns a new `LinkedHashMap` object with the values mapped according to the provided callback
1385
- * function.
1386
- */
1492
+ * Time Complexity: O(n)
1493
+ * Space Complexity: O(n)
1494
+ * /
1495
+
1496
+ /**
1497
+ * Time Complexity: O(n)
1498
+ * Space Complexity: O(n)
1499
+ *
1500
+ * The `map` function in TypeScript creates a new `LinkedHashMap` by applying a callback function to
1501
+ * each key-value pair in the original map.
1502
+ * @param callback - The callback parameter is a function that will be called for each key-value pair
1503
+ * in the map. It takes four arguments: the value of the current key-value pair, the key of the
1504
+ * current key-value pair, the index of the current key-value pair, and the map itself. The callback
1505
+ * function should
1506
+ * @param {any} [thisArg] - The `thisArg` parameter is an optional argument that allows you to
1507
+ * specify the value of `this` within the callback function. If provided, the callback function will
1508
+ * be called with `thisArg` as its `this` value. If not provided, `this` will refer to the current
1509
+ * map
1510
+ * @returns a new `LinkedHashMap` object with the values mapped according to the provided callback
1511
+ * function.
1512
+ */
1387
1513
  map(callback, thisArg) {
1388
1514
  const mappedMap = new _LinkedHashMap();
1389
1515
  let index = 0;
@@ -1413,19 +1539,29 @@ var dataStructureTyped = (() => {
1413
1539
  return this.set(key, value);
1414
1540
  }
1415
1541
  /**
1416
- * Time Complexity: O(n)
1417
- * Space Complexity: O(1)
1418
- * where n is the number of entries in the LinkedHashMap.
1419
- *
1420
- * The above function is an iterator that yields key-value pairs from a linked list.
1421
- */
1542
+ * Time Complexity: O(n)
1543
+ * Space Complexity: O(1)
1544
+ * where n is the number of entries in the LinkedHashMap.
1545
+ * /
1546
+
1547
+ /**
1548
+ * Time Complexity: O(n)
1549
+ * Space Complexity: O(1)
1550
+ * where n is the number of entries in the LinkedHashMap.
1551
+ *
1552
+ * The above function is an iterator that yields key-value pairs from a linked list.
1553
+ */
1422
1554
  *_getIterator() {
1423
- let node = this._head;
1555
+ let node = this.head;
1424
1556
  while (node !== this._sentinel) {
1425
1557
  yield [node.key, node.value];
1426
1558
  node = node.next;
1427
1559
  }
1428
1560
  }
1561
+ /**
1562
+ * Time Complexity: O(1)
1563
+ * Space Complexity: O(1)
1564
+ */
1429
1565
  /**
1430
1566
  * Time Complexity: O(1)
1431
1567
  * Space Complexity: O(1)
@@ -1440,10 +1576,10 @@ var dataStructureTyped = (() => {
1440
1576
  const { prev, next } = node;
1441
1577
  prev.next = next;
1442
1578
  next.prev = prev;
1443
- if (node === this._head) {
1579
+ if (node === this.head) {
1444
1580
  this._head = next;
1445
1581
  }
1446
- if (node === this._tail) {
1582
+ if (node === this.tail) {
1447
1583
  this._tail = prev;
1448
1584
  }
1449
1585
  this._size -= 1;
@@ -1459,10 +1595,41 @@ var dataStructureTyped = (() => {
1459
1595
  * will be stored in the node of a linked list.
1460
1596
  */
1461
1597
  constructor(value) {
1462
- __publicField(this, "value");
1463
- __publicField(this, "next");
1464
- this.value = value;
1465
- this.next = void 0;
1598
+ __publicField(this, "_value");
1599
+ __publicField(this, "_next");
1600
+ this._value = value;
1601
+ this._next = void 0;
1602
+ }
1603
+ /**
1604
+ * The function returns the value of a protected variable.
1605
+ * @returns The value of the variable `_value` is being returned.
1606
+ */
1607
+ get value() {
1608
+ return this._value;
1609
+ }
1610
+ /**
1611
+ * The above function sets the value of a variable.
1612
+ * @param {E} value - The parameter "value" is of type E, which means it can be any type.
1613
+ */
1614
+ set value(value) {
1615
+ this._value = value;
1616
+ }
1617
+ /**
1618
+ * The `next` function returns the next node in a singly linked list.
1619
+ * @returns The `next` property is being returned. It can be either a `SinglyLinkedListNode<E>`
1620
+ * object or `undefined`.
1621
+ */
1622
+ get next() {
1623
+ return this._next;
1624
+ }
1625
+ /**
1626
+ * The "next" property of a SinglyLinkedListNode is set to the provided value.
1627
+ * @param {SinglyLinkedListNode<E> | undefined} value - The `value` parameter is of type
1628
+ * `SinglyLinkedListNode<E> | undefined`. This means that it can accept either a
1629
+ * `SinglyLinkedListNode` object or `undefined` as its value.
1630
+ */
1631
+ set next(value) {
1632
+ this._next = value;
1466
1633
  }
1467
1634
  };
1468
1635
  var SinglyLinkedList = class _SinglyLinkedList extends IterableElementBase {
@@ -2103,7 +2270,7 @@ var dataStructureTyped = (() => {
2103
2270
  return filteredList;
2104
2271
  }
2105
2272
  /**
2106
- * Time Complexity: O(n), where n is the number of elements in the linked list.
2273
+ * Time Complexity: O(n)
2107
2274
  * Space Complexity: O(n)
2108
2275
  */
2109
2276
  /**
@@ -2149,12 +2316,60 @@ var dataStructureTyped = (() => {
2149
2316
  * is defined as a generic type "E".
2150
2317
  */
2151
2318
  constructor(value) {
2152
- __publicField(this, "value");
2153
- __publicField(this, "next");
2154
- __publicField(this, "prev");
2155
- this.value = value;
2156
- this.next = void 0;
2157
- this.prev = void 0;
2319
+ __publicField(this, "_value");
2320
+ __publicField(this, "_next");
2321
+ __publicField(this, "_prev");
2322
+ this._value = value;
2323
+ this._next = void 0;
2324
+ this._prev = void 0;
2325
+ }
2326
+ /**
2327
+ * The function returns the value of a protected variable.
2328
+ * @returns The value of the variable `_value` is being returned.
2329
+ */
2330
+ get value() {
2331
+ return this._value;
2332
+ }
2333
+ /**
2334
+ * The above function sets the value of a variable.
2335
+ * @param {E} value - The parameter "value" is of type E, which means it can be any type.
2336
+ */
2337
+ set value(value) {
2338
+ this._value = value;
2339
+ }
2340
+ /**
2341
+ * The "next" function returns the next node in a doubly linked list.
2342
+ * @returns The `next` property is being returned. It can be either a `DoublyLinkedListNode<E>`
2343
+ * object or `undefined`.
2344
+ */
2345
+ get next() {
2346
+ return this._next;
2347
+ }
2348
+ /**
2349
+ * The "next" property of a DoublyLinkedListNode is set to the provided value.
2350
+ * @param {DoublyLinkedListNode<E> | undefined} value - The `value` parameter is of type
2351
+ * `DoublyLinkedListNode<E> | undefined`. This means that it can accept either a
2352
+ * `DoublyLinkedListNode` object or `undefined` as its value.
2353
+ */
2354
+ set next(value) {
2355
+ this._next = value;
2356
+ }
2357
+ /**
2358
+ * The `prev` function returns the previous node in a doubly linked list.
2359
+ * @returns The `prev` property of the `DoublyLinkedListNode` class is being returned. It can either
2360
+ * be a `DoublyLinkedListNode` object or `undefined`.
2361
+ */
2362
+ get prev() {
2363
+ return this._prev;
2364
+ }
2365
+ /**
2366
+ * The function sets the previous node of a doubly linked list node.
2367
+ * @param {DoublyLinkedListNode<E> | undefined} value - The `value` parameter is of type
2368
+ * `DoublyLinkedListNode<E> | undefined`. This means that it can accept either a
2369
+ * `DoublyLinkedListNode` object or `undefined` as its value.
2370
+ */
2371
+ set prev(value) {
2372
+ this._prev = value;
2158
2373
  }
2159
2374
  };
2160
2375
  var DoublyLinkedList = class _DoublyLinkedList extends IterableElementBase {
@@ -2201,12 +2416,12 @@ var dataStructureTyped = (() => {
2201
2416
  return this._size;
2202
2417
  }
2203
2418
  /**
2204
- * Time Complexity: O(n)
2205
- * Space Complexity: O(n)
2419
+ * Time Complexity: O(1)
2420
+ * Space Complexity: O(1)
2206
2421
  * where n is the number of elements in the linked list.
2207
2422
  */
2208
2423
  /**
2209
- * Time Complexity: O(n)
2424
+ * Time Complexity: O(1)
2210
2425
  * Space Complexity: O(1)
2211
2426
  *
2212
2427
  * The `get first` function returns the first node in a doubly linked list, or undefined if the list is empty.
@@ -2221,7 +2436,7 @@ var dataStructureTyped = (() => {
2221
2436
  * Space Complexity: O(1)
2222
2437
  */
2223
2438
  /**
2224
- * Time Complexity: O(n)
2439
+ * Time Complexity: O(1)
2225
2440
  * Space Complexity: O(1)
2226
2441
  *
2227
2442
  * The `get last` function returns the last node in a doubly linked list, or undefined if the list is empty.
@@ -2232,11 +2447,11 @@ var dataStructureTyped = (() => {
2232
2447
  return (_a = this.tail) == null ? void 0 : _a.value;
2233
2448
  }
2234
2449
  /**
2235
- * Time Complexity: O(1)
2236
- * Space Complexity: O(1)
2450
+ * Time Complexity: O(n)
2451
+ * Space Complexity: O(n)
2237
2452
  */
2238
2453
  /**
2239
- * Time Complexity: O(n), where n is the size of the input array.
2454
+ * Time Complexity: O(n)
2240
2455
  * Space Complexity: O(n)
2241
2456
  *
2242
2457
  * The `fromArray` function creates a new instance of a DoublyLinkedList and populates it with the elements from the
@@ -2298,7 +2513,7 @@ var dataStructureTyped = (() => {
2298
2513
  return removedNode.value;
2299
2514
  }
2300
2515
  /**
2301
- * Time Complexity: O(n)
2516
+ * Time Complexity: O(1)
2302
2517
  * Space Complexity: O(1)
2303
2518
  */
2304
2519
  /**
@@ -2324,7 +2539,7 @@ var dataStructureTyped = (() => {
2324
2539
  return removedNode.value;
2325
2540
  }
2326
2541
  /**
2327
- * Time Complexity: O(n)
2542
+ * Time Complexity: O(1)
2328
2543
  * Space Complexity: O(1)
2329
2544
  */
2330
2545
  /**
@@ -2457,12 +2672,12 @@ var dataStructureTyped = (() => {
2457
2672
  return true;
2458
2673
  }
2459
2674
  /**
2460
- * Time Complexity: O(n)
2675
+ * Time Complexity: O(1) or O(n)
2461
2676
  * Space Complexity: O(1)
2462
2677
  * where n is the number of elements in the linked list.
2463
2678
  */
2464
2679
  /**
2465
- * Time Complexity: O(n)
2680
+ * Time Complexity: O(1) or O(n)
2466
2681
  * Space Complexity: O(1)
2467
2682
  *
2468
2683
  * The `addBefore` function inserts a new value before an existing value or node in a doubly linked list.
@@ -2498,11 +2713,11 @@ var dataStructureTyped = (() => {
2498
2713
  return false;
2499
2714
  }
2500
2715
  /**
2501
- * Time Complexity: O(n)
2716
+ * Time Complexity: O(1) or O(n)
2502
2717
  * Space Complexity: O(1)
2503
2718
  */
2504
2719
  /**
2505
- * Time Complexity: O(n)
2720
+ * Time Complexity: O(1) or O(n)
2506
2721
  * Space Complexity: O(1)
2507
2722
  *
2508
2723
  * The `addAfter` function inserts a new node with a given value after an existing node in a doubly linked list.
@@ -2566,7 +2781,11 @@ var dataStructureTyped = (() => {
2566
2781
  return true;
2567
2782
  }
2568
2783
  /**
2569
- * Time Complexity: O(n)
2784
+ * Time Complexity: O(1) or O(n)
2785
+ * Space Complexity: O(1)
2786
+ */
2787
+ /**
2788
+ * Time Complexity: O(1) or O(n)
2570
2789
  * Space Complexity: O(1)
2571
2790
  *
2572
2791
  * The `delete` function removes a node from a doubly linked list based on either the node itself or its value.
@@ -2603,6 +2822,9 @@ var dataStructureTyped = (() => {
2603
2822
  * Space Complexity: O(1)
2604
2823
  */
2605
2824
  /**
2825
+ * Time Complexity: O(1)
2826
+ * Space Complexity: O(1)
2827
+ *
2606
2828
  * The function checks if a variable has a size greater than zero and returns a boolean value.
2607
2829
  * @returns A boolean value is being returned.
2608
2830
  */
@@ -2614,6 +2836,9 @@ var dataStructureTyped = (() => {
2614
2836
  * Space Complexity: O(1)
2615
2837
  */
2616
2838
  /**
2839
+ * Time Complexity: O(1)
2840
+ * Space Complexity: O(1)
2841
+ *
2617
2842
  * The `clear` function resets the linked list by setting the head, tail, and size to undefined and 0 respectively.
2618
2843
  */
2619
2844
  clear() {
@@ -2649,7 +2874,7 @@ var dataStructureTyped = (() => {
2649
2874
  }
2650
2875
  /**
2651
2876
  * Time Complexity: O(n)
2652
- * Space Complexity: O(n)
2877
+ * Space Complexity: O(1)
2653
2878
  */
2654
2879
  /**
2655
2880
  * Time Complexity: O(n)
@@ -2674,7 +2899,7 @@ var dataStructureTyped = (() => {
2674
2899
  }
2675
2900
  /**
2676
2901
  * Time Complexity: O(n)
2677
- * Space Complexity: O(n)
2902
+ * Space Complexity: O(1)
2678
2903
  */
2679
2904
  /**
2680
2905
  * Time Complexity: O(n)
@@ -2749,9 +2974,9 @@ var dataStructureTyped = (() => {
2749
2974
  return new _DoublyLinkedList(this.values());
2750
2975
  }
2751
2976
  /**
2752
- * Time Complexity: O(1)
2753
- * Space Complexity: O(1)
2754
- */
2977
+ * Time Complexity: O(n)
2978
+ * Space Complexity: O(n)
2979
+ */
2755
2980
  /**
2756
2981
  * Time Complexity: O(n)
2757
2982
  * Space Complexity: O(n)
@@ -2781,8 +3006,8 @@ var dataStructureTyped = (() => {
2781
3006
  return filteredList;
2782
3007
  }
2783
3008
  /**
2784
- * Time Complexity: O(1)
2785
- * Space Complexity: O(1)
3009
+ * Time Complexity: O(n)
3010
+ * Space Complexity: O(n)
2786
3011
  */
2787
3012
  /**
2788
3013
  * Time Complexity: O(n)
@@ -2840,7 +3065,7 @@ var dataStructureTyped = (() => {
2840
3065
  return this.pop();
2841
3066
  }
2842
3067
  /**
2843
- * Time Complexity: O(n)
3068
+ * Time Complexity: O(1)
2844
3069
  * Space Complexity: O(1)
2845
3070
  */
2846
3071
  /**
@@ -2855,7 +3080,7 @@ var dataStructureTyped = (() => {
2855
3080
  return this.shift();
2856
3081
  }
2857
3082
  /**
2858
- * Time Complexity: O(n)
3083
+ * Time Complexity: O(1)
2859
3084
  * Space Complexity: O(1)
2860
3085
  */
2861
3086
  /**
@@ -2926,7 +3151,7 @@ var dataStructureTyped = (() => {
2926
3151
  return this._head;
2927
3152
  }
2928
3153
  /**
2929
- * The function returns the value of the private variable _level.
3154
+ * The function returns the value of the protected variable _level.
2930
3155
  * @returns The level property of the object.
2931
3156
  */
2932
3157
  get level() {
@@ -2941,7 +3166,7 @@ var dataStructureTyped = (() => {
2941
3166
  }
2942
3167
  /**
2943
3168
  * The function returns the probability value.
2944
- * @returns The probability value stored in the private variable `_probability` is being returned.
3169
+ * @returns The probability value stored in the protected variable `_probability` is being returned.
2945
3170
  */
2946
3171
  get probability() {
2947
3172
  return this._probability;
@@ -3179,10 +3404,6 @@ var dataStructureTyped = (() => {
3179
3404
  get elements() {
3180
3405
  return this._elements;
3181
3406
  }
3182
- /**
3183
- * Time Complexity: O(n), where n is the number of elements in the input array. Similar to the constructor, it requires iterating through each element.
3184
- * Space Complexity: O(n), as it creates a new stack with the elements from the input array.
3185
- */
3186
3407
  /**
3187
3408
  * The size() function returns the number of elements in an array.
3188
3409
  * @returns The size of the elements array.
@@ -3191,8 +3412,12 @@ var dataStructureTyped = (() => {
3191
3412
  return this.elements.length;
3192
3413
  }
3193
3414
  /**
3194
- * Time Complexity: O(n), where n is the number of elements in the input array. Similar to the constructor, it requires iterating through each element.
3195
- * Space Complexity: O(n), as it creates a new stack with the elements from the input array.
3415
+ * Time Complexity: O(n)
3416
+ * Space Complexity: O(n)
3417
+ */
3418
+ /**
3419
+ * Time Complexity: O(n)
3420
+ * Space Complexity: O(n)
3196
3421
  *
3197
3422
  * The function "fromArray" creates a new Stack object from an array of elements.
3198
3423
  * @param {E[]} elements - The `elements` parameter is an array of elements of type `E`.
@@ -3210,12 +3435,12 @@ var dataStructureTyped = (() => {
3210
3435
  return this.elements.length === 0;
3211
3436
  }
3212
3437
  /**
3213
- * Time Complexity: O(1), as it only involves accessing the last element of the array.
3214
- * Space Complexity: O(1), as it does not use any additional space.
3438
+ * Time Complexity: O(1)
3439
+ * Space Complexity: O(1)
3215
3440
  */
3216
3441
  /**
3217
- * Time Complexity: O(1), as it only involves accessing the last element of the array.
3218
- * Space Complexity: O(1), as it does not use any additional space.
3442
+ * Time Complexity: O(1)
3443
+ * Space Complexity: O(1)
3219
3444
  *
3220
3445
  * The `peek` function returns the last element of an array, or undefined if the array is empty.
3221
3446
  * @returns The `peek()` function returns the last element of the `_elements` array, or `undefined` if the array is empty.
@@ -3226,12 +3451,12 @@ var dataStructureTyped = (() => {
3226
3451
  return this.elements[this.elements.length - 1];
3227
3452
  }
3228
3453
  /**
3229
- * Time Complexity: O(1), as it only involves accessing the last element of the array.
3230
- * Space Complexity: O(1), as it does not use any additional space.
3454
+ * Time Complexity: O(1)
3455
+ * Space Complexity: O(1)
3231
3456
  */
3232
3457
  /**
3233
- * Time Complexity: O(1), as it only involves accessing the last element of the array.
3234
- * Space Complexity: O(1), as it does not use any additional space.
3458
+ * Time Complexity: O(1)
3459
+ * Space Complexity: O(1)
3235
3460
  *
3236
3461
  * The push function adds an element to the stack and returns the updated stack.
3237
3462
  * @param {E} element - The parameter "element" is of type E, which means it can be any data type.
@@ -3242,12 +3467,12 @@ var dataStructureTyped = (() => {
3242
3467
  return true;
3243
3468
  }
3244
3469
  /**
3245
- * Time Complexity: O(1), as it only involves accessing the last element of the array.
3246
- * Space Complexity: O(1), as it does not use any additional space.
3470
+ * Time Complexity: O(1)
3471
+ * Space Complexity: O(1)
3247
3472
  */
3248
3473
  /**
3249
- * Time Complexity: O(1), as it only involves accessing the last element of the array.
3250
- * Space Complexity: O(1), as it does not use any additional space.
3474
+ * Time Complexity: O(1)
3475
+ * Space Complexity: O(1)
3251
3476
  *
3252
3477
  * The `pop` function removes and returns the last element from an array, or returns undefined if the array is empty.
3253
3478
  * @returns The `pop()` method is returning the last element of the array `_elements` if the array is not empty. If the
@@ -3291,18 +3516,25 @@ var dataStructureTyped = (() => {
3291
3516
  return this.elements.slice();
3292
3517
  }
3293
3518
  /**
3519
+ * Time Complexity: O(1)
3520
+ * Space Complexity: O(1)
3521
+ */
3522
+ /**
3523
+ * Time Complexity: O(1)
3524
+ * Space Complexity: O(1)
3525
+ *
3294
3526
  * The clear function clears the elements array.
3295
3527
  */
3296
3528
  clear() {
3297
3529
  this._elements = [];
3298
3530
  }
3299
3531
  /**
3300
- * Time Complexity: O(n), where n is the number of elements in the stack, as it creates a new stack and copies all elements into it.
3301
- * Space Complexity: O(n), as it creates a new stack.
3532
+ * Time Complexity: O(n)
3533
+ * Space Complexity: O(n)
3302
3534
  */
3303
3535
  /**
3304
- * Time Complexity: O(n), where n is the number of elements in the stack, as it creates a new stack and copies all elements into it.
3305
- * Space Complexity: O(n), as it creates a new stack.
3536
+ * Time Complexity: O(n)
3537
+ * Space Complexity: O(n)
3306
3538
  *
3307
3539
  * The `clone()` function returns a new `Stack` object with the same elements as the original stack.
3308
3540
  * @returns The `clone()` method is returning a new `Stack` object with a copy of the `_elements` array.
@@ -3368,6 +3600,13 @@ var dataStructureTyped = (() => {
3368
3600
  return newStack;
3369
3601
  }
3370
3602
  /**
3603
+ * Time Complexity: O(n)
3604
+ * Space Complexity: O(n)
3605
+ */
3606
+ /**
3607
+ * Time Complexity: O(n)
3608
+ * Space Complexity: O(n)
3609
+ *
3371
3610
  * Custom iterator for the Stack class.
3372
3611
  * @returns An iterator object.
3373
3612
  */
@@ -3404,7 +3643,7 @@ var dataStructureTyped = (() => {
3404
3643
  }
3405
3644
  /**
3406
3645
  * The offset function returns the offset of the current page.
3407
- * @return The value of the private variable _offset
3646
+ * @return The value of the protected variable _offset
3408
3647
  */
3409
3648
  get offset() {
3410
3649
  return this._offset;
@@ -3417,8 +3656,12 @@ var dataStructureTyped = (() => {
3417
3656
  return this.elements.length - this.offset;
3418
3657
  }
3419
3658
  /**
3420
- * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
3421
- * Space Complexity: O(1) - no additional space is used.
3659
+ * Time Complexity: O(1)
3660
+ * Space Complexity: O(1)
3661
+ */
3662
+ /**
3663
+ * Time Complexity: O(1)
3664
+ * Space Complexity: O(1)
3422
3665
  *
3423
3666
  * The `first` function returns the first element of the array `_elements` if it exists, otherwise it returns `undefined`.
3424
3667
  * @returns The `get first()` method returns the first element of the data structure, represented by the `_elements` array at
@@ -3428,12 +3671,12 @@ var dataStructureTyped = (() => {
3428
3671
  return this.size > 0 ? this.elements[this.offset] : void 0;
3429
3672
  }
3430
3673
  /**
3431
- * Time Complexity: O(1) - constant time as it adds an element to the end of the array.
3432
- * Space Complexity: O(1) - no additional space is used.
3674
+ * Time Complexity: O(1)
3675
+ * Space Complexity: O(1)
3433
3676
  */
3434
3677
  /**
3435
- * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
3436
- * Space Complexity: O(1) - no additional space is used.
3678
+ * Time Complexity: O(1)
3679
+ * Space Complexity: O(1)
3437
3680
  *
3438
3681
  * The `last` function returns the last element in an array-like data structure, or undefined if the structure is empty.
3439
3682
  * @returns The method `get last()` returns the last element of the `_elements` array if the array is not empty. If the
@@ -3443,10 +3686,13 @@ var dataStructureTyped = (() => {
3443
3686
  return this.size > 0 ? this.elements[this.elements.length - 1] : void 0;
3444
3687
  }
3445
3688
  /**
3446
- * Time Complexity: O(n) - where n is the number of elements in the queue. In the worst case, it may need to shift all elements to update the offset.
3447
- * Space Complexity: O(1) - no additional space is used.
3689
+ * Time Complexity: O(n)
3690
+ * Space Complexity: O(n)
3448
3691
  */
3449
3692
  /**
3693
+ * Time Complexity: O(n)
3694
+ * Space Complexity: O(n)
3695
+ *
3450
3696
  * The function "fromArray" creates a new Queue object from an array of elements.Creates a queue from an existing array.
3451
3697
  * @public
3452
3698
  * @static
@@ -3458,12 +3704,12 @@ var dataStructureTyped = (() => {
3458
3704
  return new _Queue(elements);
3459
3705
  }
3460
3706
  /**
3461
- * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
3462
- * Space Complexity: O(1) - no additional space is used.
3707
+ * Time Complexity: O(1)
3708
+ * Space Complexity: O(1)
3463
3709
  */
3464
3710
  /**
3465
- * Time Complexity: O(1) - constant time as it adds an element to the end of the array.
3466
- * Space Complexity: O(1) - no additional space is used.
3711
+ * Time Complexity: O(1)
3712
+ * Space Complexity: O(1)
3467
3713
  *
3468
3714
  * The push function adds an element to the end of the queue and returns the updated queue.Adds an element at the back of the queue.
3469
3715
  * @param {E} element - The `element` parameter represents the element that you want to add to the queue.
@@ -3474,12 +3720,12 @@ var dataStructureTyped = (() => {
3474
3720
  return true;
3475
3721
  }
3476
3722
  /**
3477
- * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
3478
- * Space Complexity: O(1) - no additional space is used.
3723
+ * Time Complexity: O(1)
3724
+ * Space Complexity: O(1)
3479
3725
  */
3480
3726
  /**
3481
- * Time Complexity: O(n) - where n is the number of elements in the queue. In the worst case, it may need to shift all elements to update the offset.
3482
- * Space Complexity: O(1) - no additional space is used.
3727
+ * Time Complexity: O(1)
3728
+ * Space Complexity: O(1)
3483
3729
  *
3484
3730
  * The `shift` function removes and returns the first element in the queue, and adjusts the internal data structure if
3485
3731
  * necessary to optimize performance.
@@ -3515,12 +3761,12 @@ var dataStructureTyped = (() => {
3515
3761
  return spliced.length === 1;
3516
3762
  }
3517
3763
  /**
3518
- * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
3519
- * Space Complexity: O(1) - no additional space is used.
3764
+ * Time Complexity: O(1)
3765
+ * Space Complexity: O(1)
3520
3766
  */
3521
3767
  /**
3522
- * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
3523
- * Space Complexity: O(1) - no additional space is used.
3768
+ * Time Complexity: O(1)
3769
+ * Space Complexity: O(1)
3524
3770
  *
3525
3771
  * The `peek` function returns the first element of the array `_elements` if it exists, otherwise it returns `undefined`.
3526
3772
  * @returns The `peek()` method returns the first element of the data structure, represented by the `_elements` array at
@@ -3530,12 +3776,12 @@ var dataStructureTyped = (() => {
3530
3776
  return this.first;
3531
3777
  }
3532
3778
  /**
3533
- * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
3534
- * Space Complexity: O(1) - no additional space is used.
3779
+ * Time Complexity: O(1)
3780
+ * Space Complexity: O(1)
3535
3781
  */
3536
3782
  /**
3537
- * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
3538
- * Space Complexity: O(1) - no additional space is used.
3783
+ * Time Complexity: O(1)
3784
+ * Space Complexity: O(1)
3539
3785
  *
3540
3786
  * The `peekLast` function returns the last element in an array-like data structure, or undefined if the structure is empty.
3541
3787
  * @returns The method `peekLast()` returns the last element of the `_elements` array if the array is not empty. If the
@@ -3545,12 +3791,12 @@ var dataStructureTyped = (() => {
3545
3791
  return this.last;
3546
3792
  }
3547
3793
  /**
3548
- * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
3549
- * Space Complexity: O(1) - no additional space is used.
3794
+ * Time Complexity: O(1)
3795
+ * Space Complexity: O(1)
3550
3796
  */
3551
3797
  /**
3552
- * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
3553
- * Space Complexity: O(1) - no additional space is used.
3798
+ * Time Complexity: O(1)
3799
+ * Space Complexity: O(1)
3554
3800
  *
3555
3801
  * The enqueue function adds a value to the end of a queue.
3556
3802
  * @param {E} value - The value parameter represents the value that you want to add to the queue.
@@ -3559,12 +3805,12 @@ var dataStructureTyped = (() => {
3559
3805
  return this.push(value);
3560
3806
  }
3561
3807
  /**
3562
- * Time Complexity: O(n) - same as shift().
3563
- * Space Complexity: O(1) - same as shift().
3808
+ * Time Complexity: O(1)
3809
+ * Space Complexity: O(1)
3564
3810
  */
3565
3811
  /**
3566
- * Time Complexity: O(n) - same as shift().
3567
- * Space Complexity: O(1) - same as shift().
3812
+ * Time Complexity: O(1)
3813
+ * Space Complexity: O(1)
3568
3814
  *
3569
3815
  * The `dequeue` function removes and returns the first element from a queue, or returns undefined if the queue is empty.
3570
3816
  * @returns The method is returning a value of type E or undefined.
@@ -3573,12 +3819,12 @@ var dataStructureTyped = (() => {
3573
3819
  return this.shift();
3574
3820
  }
3575
3821
  /**
3576
- * Time Complexity: O(1) - constant time as it retrieves the value at the specified index.
3577
- * Space Complexity: O(1) - no additional space is used.
3822
+ * Time Complexity: O(1)
3823
+ * Space Complexity: O(1)
3578
3824
  */
3579
3825
  /**
3580
- * Time Complexity: O(1) - constant time as it retrieves the value at the specified index.
3581
- * Space Complexity: O(1) - no additional space is used.
3826
+ * Time Complexity: O(1)
3827
+ * Space Complexity: O(1)
3582
3828
  *
3583
3829
  * @param index
3584
3830
  */
@@ -3586,12 +3832,12 @@ var dataStructureTyped = (() => {
3586
3832
  return this.elements[index];
3587
3833
  }
3588
3834
  /**
3589
- * Time Complexity: O(1) - constant time as it retrieves the value at the specified index.
3590
- * Space Complexity: O(1) - no additional space is used.
3835
+ * Time Complexity: O(1)
3836
+ * Space Complexity: O(1)
3591
3837
  */
3592
3838
  /**
3593
- * Time Complexity: O(1) - constant time as it retrieves the value at the specified index.
3594
- * Space Complexity: O(1) - no additional space is used.
3839
+ * Time Complexity: O(1)
3840
+ * Space Complexity: O(1)
3595
3841
  *
3596
3842
  * The function checks if a data structure is empty by comparing its size to zero.
3597
3843
  * @returns {boolean} A boolean value indicating whether the size of the object is 0 or not.
@@ -3600,12 +3846,12 @@ var dataStructureTyped = (() => {
3600
3846
  return this.size === 0;
3601
3847
  }
3602
3848
  /**
3603
- * Time Complexity: O(1) - constant time as it returns a shallow copy of the internal array.
3604
- * Space Complexity: O(n) - where n is the number of elements in the queue.
3849
+ * Time Complexity: O(1)
3850
+ * Space Complexity: O(n)
3605
3851
  */
3606
3852
  /**
3607
- * Time Complexity: O(1) - constant time as it returns a shallow copy of the internal array.
3608
- * Space Complexity: O(n) - where n is the number of elements in the queue.
3853
+ * Time Complexity: O(1)
3854
+ * Space Complexity: O(n)
3609
3855
  *
3610
3856
  * The toArray() function returns an array of elements from the current offset to the end of the _elements array.
3611
3857
  * @returns An array of type E is being returned.
@@ -3614,6 +3860,13 @@ var dataStructureTyped = (() => {
3614
3860
  return this.elements.slice(this.offset);
3615
3861
  }
3616
3862
  /**
3863
+ * Time Complexity: O(1)
3864
+ * Space Complexity: O(1)
3865
+ */
3866
+ /**
3867
+ * Time Complexity: O(1)
3868
+ * Space Complexity: O(1)
3869
+ *
3617
3870
  * The clear function resets the elements array and offset to their initial values.
3618
3871
  */
3619
3872
  clear() {
@@ -3697,6 +3950,12 @@ var dataStructureTyped = (() => {
3697
3950
  * Time Complexity: O(n)
3698
3951
  * Space Complexity: O(n)
3699
3952
  */
3953
+ /**
3954
+ * Time Complexity: O(n)
3955
+ * Space Complexity: O(n)
3956
+ *
3957
+ * The function `_getIterator` returns an iterable iterator for the elements in the class.
3958
+ */
3700
3959
  *_getIterator() {
3701
3960
  for (const item of this.elements) {
3702
3961
  yield item;
@@ -3765,12 +4024,12 @@ var dataStructureTyped = (() => {
3765
4024
  */
3766
4025
  constructor(elements = [], options) {
3767
4026
  super();
4027
+ __publicField(this, "_bucketSize", 1 << 12);
3768
4028
  __publicField(this, "_bucketFirst", 0);
3769
4029
  __publicField(this, "_firstInBucket", 0);
3770
4030
  __publicField(this, "_bucketLast", 0);
3771
4031
  __publicField(this, "_lastInBucket", 0);
3772
4032
  __publicField(this, "_bucketCount", 0);
3773
- __publicField(this, "_bucketSize", 1 << 12);
3774
4033
  __publicField(this, "_buckets", []);
3775
4034
  __publicField(this, "_size", 0);
3776
4035
  if (options) {
@@ -3809,9 +4068,45 @@ var dataStructureTyped = (() => {
3809
4068
  get bucketSize() {
3810
4069
  return this._bucketSize;
3811
4070
  }
4071
+ /**
4072
+ * The function returns the value of the protected variable `_bucketFirst`.
4073
+ * @returns The value of the `_bucketFirst` property.
4074
+ */
4075
+ get bucketFirst() {
4076
+ return this._bucketFirst;
4077
+ }
4078
+ /**
4079
+ * The function returns the value of the protected variable _firstInBucket.
4080
+ * @returns The method is returning the value of the variable `_firstInBucket`, which is of type
4081
+ * `number`.
4082
+ */
4083
+ get firstInBucket() {
4084
+ return this._firstInBucket;
4085
+ }
4086
+ /**
4087
+ * The function returns the value of the protected variable `_bucketLast`.
4088
+ * @returns The value of the `_bucketLast` property, which is a number.
4089
+ */
4090
+ get bucketLast() {
4091
+ return this._bucketLast;
4092
+ }
4093
+ /**
4094
+ * The function returns the value of the protected variable _lastInBucket.
4095
+ * @returns The method is returning the value of the variable `_lastInBucket`, which is of type
4096
+ * `number`.
4097
+ */
4098
+ get lastInBucket() {
4099
+ return this._lastInBucket;
4100
+ }
4101
+ /**
4102
+ * The function returns the number of buckets.
4103
+ * @returns The number of buckets.
4104
+ */
4105
+ get bucketCount() {
4106
+ return this._bucketCount;
4107
+ }
3812
4108
  /**
3813
4109
  * The buckets function returns the buckets property of the object.
3814
- *
3815
4110
  * @return The buckets property
3816
4111
  */
3817
4112
  get buckets() {
@@ -3968,13 +4263,27 @@ var dataStructureTyped = (() => {
3968
4263
  return element;
3969
4264
  }
3970
4265
  /**
3971
- * Time Complexity: O(1) - Removes the last element.
3972
- * Space Complexity: O(1) - Operates in-place.
4266
+ * Time Complexity: O(1)
4267
+ * Space Complexity: O(1)
4268
+ */
4269
+ /**
4270
+ * Time Complexity: O(1)
4271
+ * Space Complexity: O(1)
4272
+ *
4273
+ * The function checks if the size of an object is equal to zero and returns a boolean value.
4274
+ * @returns A boolean value indicating whether the size of the object is 0 or not.
3973
4275
  */
3974
4276
  isEmpty() {
3975
4277
  return this.size === 0;
3976
4278
  }
3977
4279
  /**
4280
+ * Time Complexity: O(1)
4281
+ * Space Complexity: O(1)
4282
+ */
4283
+ /**
4284
+ * Time Complexity: O(1)
4285
+ * Space Complexity: O(1)
4286
+ *
3978
4287
  * The clear() function resets the state of the object by initializing all variables to their default
3979
4288
  * values.
3980
4289
  */
@@ -4119,6 +4428,25 @@ var dataStructureTyped = (() => {
4119
4428
  return newDeque;
4120
4429
  }
4121
4430
  }
4431
+ /**
4432
+ * Time Complexity: O(1)
4433
+ * Space Complexity: O(1) or O(n)
4434
+ */
4435
+ /**
4436
+ * Time Complexity: O(1)
4437
+ * Space Complexity: O(1) or O(n)
4438
+ *
4439
+ * The `cutRest` function cuts the elements from a specified position in a deque and returns a new
4440
+ * deque with the cut elements.
4441
+ * @param {number} pos - The `pos` parameter represents the position from which to cut the Deque. It
4442
+ * is a number that indicates the index of the element in the Deque where the cut should start.
4443
+ * @param [isCutSelf=false] - isCutSelf is a boolean parameter that determines whether the original
4444
+ * Deque should be modified or a new Deque should be created. If isCutSelf is true, the original
4445
+ * Deque will be modified by cutting off elements starting from the specified position. If isCutSelf
4446
+ * is false, a new De
4447
+ * @returns The function `cutRest` returns either the modified original deque (`this`) or a new deque
4448
+ * (`newDeque`) depending on the value of the `isCutSelf` parameter.
4449
+ */
4122
4450
  cutRest(pos, isCutSelf = false) {
4123
4451
  if (isCutSelf) {
4124
4452
  if (pos < 0) {
@@ -4140,11 +4468,11 @@ var dataStructureTyped = (() => {
4140
4468
  }
4141
4469
  /**
4142
4470
  * Time Complexity: O(n)
4143
- * Space Complexity: O(1)
4471
+ * Space Complexity: O(1) or O(n)
4144
4472
  */
4145
4473
  /**
4146
4474
  * Time Complexity: O(n)
4147
- * Space Complexity: O(1)
4475
+ * Space Complexity: O(1) or O(n)
4148
4476
  *
4149
4477
  * The `deleteAt` function removes an element at a specified position in an array-like data
4150
4478
  * structure.
@@ -4430,8 +4758,8 @@ var dataStructureTyped = (() => {
4430
4758
  * Space Complexity: O(n) - Due to potential resizing.
4431
4759
  */
4432
4760
  /**
4433
- * Time Complexity: O(1)
4434
- * Space Complexity: O(n) - In worst case, resizing doubles the array size.
4761
+ * Time Complexity: Amortized O(1) - Similar to push, resizing leads to O(n).
4762
+ * Space Complexity: O(n) - Due to potential resizing.
4435
4763
  *
4436
4764
  * The addLast function adds an element to the end of an array.
4437
4765
  * @param {E} element - The element parameter represents the element that you want to add to the end of the
@@ -4441,12 +4769,12 @@ var dataStructureTyped = (() => {
4441
4769
  return this.push(element);
4442
4770
  }
4443
4771
  /**
4444
- * Time Complexity: O(1) - Removes the first element.
4445
- * Space Complexity: O(1) - In-place operation.
4772
+ * Time Complexity: O(1)
4773
+ * Space Complexity: O(1)
4446
4774
  */
4447
4775
  /**
4448
- * Time Complexity: O(1) - Removes the last element.
4449
- * Space Complexity: O(1) - Operates in-place.
4776
+ * Time Complexity: O(1)
4777
+ * Space Complexity: O(1)
4450
4778
  *
4451
4779
  * The function "pollLast" removes and returns the last element of an array.
4452
4780
  * @returns The last element of the array is being returned.
@@ -4455,34 +4783,49 @@ var dataStructureTyped = (() => {
4455
4783
  return this.pop();
4456
4784
  }
4457
4785
  /**
4458
- * Time Complexity: O(1).
4459
- * Space Complexity: O(n) - Due to potential resizing.
4460
- *
4461
- * The "addFirst" function adds an element to the beginning of an array.
4462
- * @param {E} element - The parameter "element" represents the element that you want to add to the
4463
- * beginning of the data structure.
4464
- */
4786
+ * Time Complexity: O(1)
4787
+ * Space Complexity: O(1)
4788
+ * /
4789
+
4790
+ /**
4791
+ * Time Complexity: O(1)
4792
+ * Space Complexity: O(1)
4793
+ *
4794
+ * The "addFirst" function adds an element to the beginning of an array.
4795
+ * @param {E} element - The parameter "element" represents the element that you want to add to the
4796
+ * beginning of the data structure.
4797
+ */
4465
4798
  addFirst(element) {
4466
4799
  return this.unshift(element);
4467
4800
  }
4468
4801
  /**
4469
- * Time Complexity: O(1) - Removes the first element.
4470
- * Space Complexity: O(1) - In-place operation.
4471
- *
4472
- * The function "pollFirst" removes and returns the first element of an array.
4473
- * @returns The method `pollFirst()` is returning the first element of the array after removing it
4474
- * from the beginning. If the array is empty, it will return `undefined`.
4475
- */
4802
+ * Time Complexity: O(1)
4803
+ * Space Complexity: O(1)
4804
+ * /
4805
+
4806
+ /**
4807
+ * Time Complexity: O(1)
4808
+ * Space Complexity: O(1)
4809
+ *
4810
+ * The function "pollFirst" removes and returns the first element of an array.
4811
+ * @returns The method `pollFirst()` is returning the first element of the array after removing it
4812
+ * from the beginning. If the array is empty, it will return `undefined`.
4813
+ */
4476
4814
  pollFirst() {
4477
4815
  return this.shift();
4478
4816
  }
4479
4817
  /**
4480
- * Time Complexity: O(n)
4481
- * Space Complexity: O(1)
4482
- *
4483
- * The above function is an implementation of the iterator protocol in TypeScript, allowing the
4484
- * object to be iterated over using a for...of loop.
4485
- */
4818
+ * Time Complexity: O(n)
4819
+ * Space Complexity: O(1)
4820
+ * /
4821
+
4822
+ /**
4823
+ * Time Complexity: O(n)
4824
+ * Space Complexity: O(1)
4825
+ *
4826
+ * The above function is an implementation of the iterator protocol in TypeScript, allowing the
4827
+ * object to be iterated over using a for...of loop.
4828
+ */
4486
4829
  *_getIterator() {
4487
4830
  for (let i = 0; i < this.size; ++i) {
4488
4831
  yield this.at(i);
@@ -4660,6 +5003,10 @@ var dataStructureTyped = (() => {
4660
5003
  }
4661
5004
  return value;
4662
5005
  }
5006
+ /**
5007
+ * Time Complexity: O(1)
5008
+ * Space Complexity: O(1)
5009
+ */
4663
5010
  /**
4664
5011
  * Time Complexity: O(1)
4665
5012
  * Space Complexity: O(1)
@@ -4684,11 +5031,11 @@ var dataStructureTyped = (() => {
4684
5031
  this._elements = [];
4685
5032
  }
4686
5033
  /**
4687
- * Time Complexity: O(n), where n is the number of elements in the elements array.
5034
+ * Time Complexity: O(n)
4688
5035
  * Space Complexity: O(n)
4689
5036
  */
4690
5037
  /**
4691
- * Time Complexity: O(n), where n is the number of elements in the elements array.
5038
+ * Time Complexity: O(n)
4692
5039
  * Space Complexity: O(n)
4693
5040
  *
4694
5041
  * Clear and add elements of the heap
@@ -4699,11 +5046,11 @@ var dataStructureTyped = (() => {
4699
5046
  return this.fix();
4700
5047
  }
4701
5048
  /**
4702
- * Time Complexity: O(n), where n is the number of elements in the heap.
5049
+ * Time Complexity: O(n)
4703
5050
  * Space Complexity: O(1)
4704
5051
  */
4705
5052
  /**
4706
- * Time Complexity: O(n), where n is the number of elements in the heap.
5053
+ * Time Complexity: O(n)
4707
5054
  * Space Complexity: O(1)
4708
5055
  *
4709
5056
  * Use a comparison function to check whether a binary heap contains a specific element.
@@ -4714,11 +5061,12 @@ var dataStructureTyped = (() => {
4714
5061
  return this.elements.includes(element);
4715
5062
  }
4716
5063
  /**
4717
- * Time Complexity: O(n). The worst-case O(n), where n is the number of elements in the heap. This is because, in the worst case, the element to be deleted is located at the end of the heap (not the root), and after deletion, we may need to reorganize the elements by performing a sinkDown operation.
5064
+ * Time Complexity: O(n)
4718
5065
  * Space Complexity: O(1)
5066
+ * The worst-case O(n) This is because, in the worst case, the element to be deleted is located at the end of the heap (not the root), and after deletion, we may need to reorganize the elements by performing a sinkDown operation.
4719
5067
  */
4720
5068
  /**
4721
- * Time Complexity: O(n). The worst-case O(n), where n is the number of elements in the heap. This is because, in the worst case, the element to be deleted is located at the end of the heap (not the root), and after deletion, we may need to reorganize the elements by performing a sinkDown operation.
5069
+ * Time Complexity: O(n)
4722
5070
  * Space Complexity: O(1)
4723
5071
  *
4724
5072
  * The `delete` function removes an element from an array-like data structure, maintaining the order
@@ -4744,12 +5092,13 @@ var dataStructureTyped = (() => {
4744
5092
  return true;
4745
5093
  }
4746
5094
  /**
4747
- * Time Complexity: O(n), where n is the number of elements in the heap.
4748
- * Space Complexity: O(h), where h is the height of the heap.
5095
+ * Time Complexity: O(n)
5096
+ * Space Complexity: O(log n)
5097
+ * where log n is the height of the heap.
4749
5098
  */
4750
5099
  /**
4751
- * Time Complexity: O(n), where n is the number of elements in the heap.
4752
- * Space Complexity: O(h), where h is the height of the heap.
5100
+ * Time Complexity: O(n)
5101
+ * Space Complexity: O(log n)
4753
5102
  *
4754
5103
  * Depth-first search (DFS) method, different traversal orders can be selected。
4755
5104
  * @param order - Traverse order parameter: 'in' (in-order), 'pre' (pre-order) or 'post' (post-order).
@@ -4830,12 +5179,12 @@ var dataStructureTyped = (() => {
4830
5179
  return visitedNode;
4831
5180
  }
4832
5181
  /**
4833
- * Time Complexity: O(log n)
4834
- * Space Complexity: O(1)
5182
+ * Time Complexity: O(n log n)
5183
+ * Space Complexity: O(n)
4835
5184
  */
4836
5185
  /**
4837
- * Time Complexity: O(n)
4838
- * Space Complexity: O(1)
5186
+ * Time Complexity: O(n log n)
5187
+ * Space Complexity: O(n)
4839
5188
  *
4840
5189
  * Fix the entire heap to maintain heap properties.
4841
5190
  */
@@ -4918,7 +5267,7 @@ var dataStructureTyped = (() => {
4918
5267
  }
4919
5268
  }
4920
5269
  /**
4921
- * Time Complexity: O(n)
5270
+ * Time Complexity: O(log n)
4922
5271
  * Space Complexity: O(1)
4923
5272
  */
4924
5273
  /**
@@ -4941,6 +5290,10 @@ var dataStructureTyped = (() => {
4941
5290
  this.elements[index] = element;
4942
5291
  return true;
4943
5292
  }
5293
+ /**
5294
+ * Time Complexity: O(log n)
5295
+ * Space Complexity: O(1)
5296
+ */
4944
5297
  /**
4945
5298
  * Time Complexity: O(log n)
4946
5299
  * Space Complexity: O(1)
@@ -5151,11 +5504,11 @@ var dataStructureTyped = (() => {
5151
5504
  }
5152
5505
  }
5153
5506
  /**
5154
- * Time Complexity: O(log n), where n is the number of elements in the heap.
5507
+ * Time Complexity: O(log n)
5155
5508
  * Space Complexity: O(1)
5156
5509
  */
5157
5510
  /**
5158
- * Time Complexity: O(log n), where n is the number of elements in the heap.
5511
+ * Time Complexity: O(log n)
5159
5512
  * Space Complexity: O(1)
5160
5513
  *
5161
5514
  * Remove and return the top element (smallest or largest element) from the heap.
@@ -5165,11 +5518,11 @@ var dataStructureTyped = (() => {
5165
5518
  return this.pop();
5166
5519
  }
5167
5520
  /**
5168
- * Time Complexity: O(log n), where n is the number of elements in the heap.
5521
+ * Time Complexity: O(log n)
5169
5522
  * Space Complexity: O(1)
5170
5523
  */
5171
5524
  /**
5172
- * Time Complexity: O(log n), where n is the number of elements in the heap.
5525
+ * Time Complexity: O(log n)
5173
5526
  * Space Complexity: O(1)
5174
5527
  *
5175
5528
  * Remove and return the top element (smallest or largest element) from the heap.
@@ -6185,200 +6538,18 @@ var dataStructureTyped = (() => {
6185
6538
  return { costs, predecessor };
6186
6539
  }
6187
6540
  /**
6188
- * Time Complexity: O(V + E) - Linear time (Tarjan's algorithm).
6189
- * Space Complexity: O(V) - Linear space (Tarjan's algorithm).
6190
- * Tarjan is an algorithm based on dfs,which is used to solve the connectivity problem of graphs.
6191
- * Tarjan can find cycles in directed or undirected graph
6192
- * Tarjan can find the articulation points and bridges(critical edgeMap) of undirected graphs in linear time,
6193
- * Tarjan solve the bi-connected components of undirected graphs;
6194
- * Tarjan can find the SSC(strongly connected components), articulation points, and bridges of directed graphs.
6195
- * /
6196
-
6197
- /**
6198
- * Time Complexity: O(V + E) - Linear time (Tarjan's algorithm).
6199
- * Space Complexity: O(V) - Linear space (Tarjan's algorithm).
6200
- *
6201
- * Tarjan is an algorithm based on dfs,which is used to solve the connectivity problem of graphs.
6202
- * Tarjan can find cycles in directed or undirected graph
6203
- * Tarjan can find the articulation points and bridges(critical edgeMap) of undirected graphs in linear time,
6204
- * Tarjan solve the bi-connected components of undirected graphs;
6205
- * Tarjan can find the SSC(strongly connected components), articulation points, and bridges of directed graphs.
6206
- * The `tarjan` function is used to perform various graph analysis tasks such as finding articulation points, bridges,
6207
- * strongly connected components (SCCs), and cycles in a graph.
6208
- * @param {boolean} [needCutVertexes] - A boolean value indicating whether or not to calculate and return the
6209
- * articulation points in the graph. Articulation points are the vertexMap in a graph whose removal would increase the
6210
- * number of connected components in the graph.
6211
- * @param {boolean} [needBridges] - A boolean flag indicating whether the algorithm should find and return the bridges
6212
- * (edgeMap whose removal would increase the number of connected components in the graph).
6213
- * @param {boolean} [needSCCs] - A boolean value indicating whether the Strongly Connected Components (SCCs) of the
6214
- * graph are needed. If set to true, the function will calculate and return the SCCs of the graph. If set to false, the
6215
- * SCCs will not be calculated or returned.
6216
- * @param {boolean} [needCycles] - A boolean flag indicating whether the algorithm should find cycles in the graph. If
6217
- * set to true, the algorithm will return a map of cycles, where the keys are the low values of the SCCs and the values
6218
- * are arrays of vertexMap that form cycles within the SCCs.
6219
- * @returns The function `tarjan` returns an object with the following properties:
6220
- */
6221
- tarjan(needCutVertexes = false, needBridges = false, needSCCs = true, needCycles = false) {
6222
- const defaultConfig = false;
6223
- if (needCutVertexes === void 0)
6224
- needCutVertexes = defaultConfig;
6225
- if (needBridges === void 0)
6226
- needBridges = defaultConfig;
6227
- if (needSCCs === void 0)
6228
- needSCCs = defaultConfig;
6229
- if (needCycles === void 0)
6230
- needCycles = defaultConfig;
6231
- const dfnMap = /* @__PURE__ */ new Map();
6232
- const lowMap = /* @__PURE__ */ new Map();
6233
- const vertexMap = this._vertexMap;
6234
- vertexMap.forEach((v) => {
6235
- dfnMap.set(v, -1);
6236
- lowMap.set(v, Infinity);
6237
- });
6238
- const [root] = vertexMap.values();
6239
- const cutVertexes = [];
6240
- const bridges = [];
6241
- let dfn = 0;
6242
- const dfs = (cur, parent) => {
6243
- dfn++;
6244
- dfnMap.set(cur, dfn);
6245
- lowMap.set(cur, dfn);
6246
- const neighbors = this.getNeighbors(cur);
6247
- let childCount = 0;
6248
- for (const neighbor of neighbors) {
6249
- if (neighbor !== parent) {
6250
- if (dfnMap.get(neighbor) === -1) {
6251
- childCount++;
6252
- dfs(neighbor, cur);
6253
- }
6254
- const childLow = lowMap.get(neighbor);
6255
- const curLow = lowMap.get(cur);
6256
- if (curLow !== void 0 && childLow !== void 0) {
6257
- lowMap.set(cur, Math.min(curLow, childLow));
6258
- }
6259
- const curFromMap = dfnMap.get(cur);
6260
- if (childLow !== void 0 && curFromMap !== void 0) {
6261
- if (needCutVertexes) {
6262
- if (cur === root && childCount >= 2 || cur !== root && childLow >= curFromMap) {
6263
- cutVertexes.push(cur);
6264
- }
6265
- }
6266
- if (needBridges) {
6267
- if (childLow > curFromMap) {
6268
- const edgeCurToNeighbor = this.getEdge(cur, neighbor);
6269
- if (edgeCurToNeighbor) {
6270
- bridges.push(edgeCurToNeighbor);
6271
- }
6272
- }
6273
- }
6274
- }
6541
+ * O(V+E+C)
6542
+ * O(V+C)
6543
+ */
6544
+ getCycles(isInclude2Cycle = false) {
6545
+ const cycles = [];
6546
+ const visited = /* @__PURE__ */ new Set();
6547
+ const dfs = (vertex, currentPath, visited2) => {
6548
+ if (visited2.has(vertex)) {
6549
+ if ((!isInclude2Cycle && currentPath.length > 2 || isInclude2Cycle && currentPath.length >= 2) && currentPath[0] === vertex.key) {
6550
+ cycles.push([...currentPath]);
6275
6551
  }
6276
- }
6277
- };
6278
- dfs(root, void 0);
6279
- let SCCs = /* @__PURE__ */ new Map();
6280
- const getSCCs = () => {
6281
- const SCCs2 = /* @__PURE__ */ new Map();
6282
- lowMap.forEach((low, vertex) => {
6283
- var _a;
6284
- if (!SCCs2.has(low)) {
6285
- SCCs2.set(low, [vertex]);
6286
- } else {
6287
- (_a = SCCs2.get(low)) == null ? void 0 : _a.push(vertex);
6288
- }
6289
- });
6290
- return SCCs2;
6291
- };
6292
- if (needSCCs) {
6293
- SCCs = getSCCs();
6294
- }
6295
- const cycles = /* @__PURE__ */ new Map();
6296
- if (needCycles) {
6297
- const visitedMap = /* @__PURE__ */ new Map();
6298
- const stack = [];
6299
- const findCyclesDFS = (cur, parent) => {
6300
- visitedMap.set(cur, true);
6301
- stack.push(cur);
6302
- const neighbors = this.getNeighbors(cur);
6303
- for (const neighbor of neighbors) {
6304
- if (!visitedMap.get(neighbor)) {
6305
- findCyclesDFS(neighbor, cur);
6306
- } else if (stack.includes(neighbor) && neighbor !== parent) {
6307
- const cycleStartIndex = stack.indexOf(neighbor);
6308
- const cycle = stack.slice(cycleStartIndex);
6309
- const cycleLow = Math.min(...cycle.map((v) => dfnMap.get(v) || Infinity));
6310
- cycles.set(cycleLow, cycle);
6311
- }
6312
- }
6313
- stack.pop();
6314
- };
6315
- vertexMap.forEach((v) => {
6316
- if (!visitedMap.get(v)) {
6317
- findCyclesDFS(v, void 0);
6318
- }
6319
- });
6320
- }
6321
- return { dfnMap, lowMap, bridges, cutVertexes, SCCs, cycles };
6322
- }
6323
- /**
6324
- * Time Complexity: O(V + E) - Depends on the implementation (Tarjan's algorithm).
6325
- * Space Complexity: O(V) - Depends on the implementation (Tarjan's algorithm).
6326
- */
6327
- /**
6328
- * Time Complexity: O(V + E) - Depends on the implementation (Tarjan's algorithm).
6329
- * Space Complexity: O(V) - Depends on the implementation (Tarjan's algorithm).
6330
- *
6331
- * The function returns a map that associates each vertex object with its corresponding depth-first
6332
- * number.
6333
- * @returns A Map object with keys of type VO and values of type number.
6334
- */
6335
- getDFNMap() {
6336
- return this.tarjan(false, false, false, false).dfnMap;
6337
- }
6338
- /**
6339
- * The function returns a Map object that contains the low values of each vertex in a Tarjan
6340
- * algorithm.
6341
- * @returns The method `getLowMap()` is returning a `Map` object with keys of type `VO` and values of
6342
- * type `number`.
6343
- */
6344
- getLowMap() {
6345
- return this.tarjan(false, false, false, false).lowMap;
6346
- }
6347
- /**
6348
- * The function "getCutVertexes" returns an array of cut vertexes using the Tarjan algorithm.
6349
- * @returns an array of VO objects, specifically the cut vertexes.
6350
- */
6351
- getCutVertexes() {
6352
- return this.tarjan(true, false, false, false).cutVertexes;
6353
- }
6354
- /**
6355
- * The function "getSCCs" returns a map of strongly connected components (SCCs) using the Tarjan
6356
- * algorithm.
6357
- * @returns a map where the keys are numbers and the values are arrays of VO objects.
6358
- */
6359
- getSCCs() {
6360
- return this.tarjan(false, false, true, false).SCCs;
6361
- }
6362
- /**
6363
- * The function "getBridges" returns an array of bridges using the Tarjan algorithm.
6364
- * @returns the bridges found using the Tarjan algorithm.
6365
- */
6366
- getBridges() {
6367
- return this.tarjan(false, true, false, false).bridges;
6368
- }
6369
- /**
6370
- * O(V+E+C)
6371
- * O(V+C)
6372
- */
6373
- getCycles(isInclude2Cycle = false) {
6374
- const cycles = [];
6375
- const visited = /* @__PURE__ */ new Set();
6376
- const dfs = (vertex, currentPath, visited2) => {
6377
- if (visited2.has(vertex)) {
6378
- if ((!isInclude2Cycle && currentPath.length > 2 || isInclude2Cycle && currentPath.length >= 2) && currentPath[0] === vertex.key) {
6379
- cycles.push([...currentPath]);
6380
- }
6381
- return;
6552
+ return;
6382
6553
  }
6383
6554
  visited2.add(vertex);
6384
6555
  currentPath.push(vertex.key);
@@ -7011,6 +7182,21 @@ var dataStructureTyped = (() => {
7011
7182
  isEmpty() {
7012
7183
  return this.vertexMap.size === 0 && this.inEdgeMap.size === 0 && this.outEdgeMap.size === 0;
7013
7184
  }
7185
+ /**
7186
+ * Time Complexity: O(1)
7187
+ * Space Complexity: O(1)
7188
+ */
7189
+ /**
7190
+ * Time Complexity: O(1)
7191
+ * Space Complexity: O(1)
7192
+ *
7193
+ * The clear function resets the vertex map, in-edge map, and out-edge map.
7194
+ */
7195
+ clear() {
7196
+ this._vertexMap = /* @__PURE__ */ new Map();
7197
+ this._inEdgeMap = /* @__PURE__ */ new Map();
7198
+ this._outEdgeMap = /* @__PURE__ */ new Map();
7199
+ }
7014
7200
  /**
7015
7201
  * The clone function creates a new DirectedGraph object with the same vertices and edges as the original.
7016
7202
  *
@@ -7023,6 +7209,95 @@ var dataStructureTyped = (() => {
7023
7209
  cloned.outEdgeMap = new Map(this.outEdgeMap);
7024
7210
  return cloned;
7025
7211
  }
7212
+ /**
7213
+ * Time Complexity: O(V + E)
7214
+ * Space Complexity: O(V)
7215
+ * Tarjan is an algorithm based on dfs,which is used to solve the connectivity problem of graphs.
7216
+ * Tarjan can find the SSC(strongly connected components), articulation points, and bridges of directed graphs.
7217
+ */
7218
+ /**
7219
+ * Time Complexity: O(V + E)
7220
+ * Space Complexity: O(V)
7221
+ * Tarjan is an algorithm based on dfs,which is used to solve the connectivity problem of graphs.
7222
+ * Tarjan can find the SSC(strongly connected components), articulation points, and bridges of directed graphs.
7223
+ *
7224
+ * The function `tarjan` implements the Tarjan's algorithm to find strongly connected components in a
7225
+ * graph.
7226
+ * @returns The function `tarjan()` returns an object with three properties: `dfnMap`, `lowMap`, and
7227
+ * `SCCs`.
7228
+ */
7229
+ tarjan() {
7230
+ const dfnMap = /* @__PURE__ */ new Map();
7231
+ const lowMap = /* @__PURE__ */ new Map();
7232
+ const SCCs = /* @__PURE__ */ new Map();
7233
+ let time = 0;
7234
+ const stack = [];
7235
+ const inStack = /* @__PURE__ */ new Set();
7236
+ const dfs = (vertex) => {
7237
+ dfnMap.set(vertex, time);
7238
+ lowMap.set(vertex, time);
7239
+ time++;
7240
+ stack.push(vertex);
7241
+ inStack.add(vertex);
7242
+ const neighbors = this.getNeighbors(vertex);
7243
+ for (const neighbor of neighbors) {
7244
+ if (!dfnMap.has(neighbor)) {
7245
+ dfs(neighbor);
7246
+ lowMap.set(vertex, Math.min(lowMap.get(vertex), lowMap.get(neighbor)));
7247
+ } else if (inStack.has(neighbor)) {
7248
+ lowMap.set(vertex, Math.min(lowMap.get(vertex), dfnMap.get(neighbor)));
7249
+ }
7250
+ }
7251
+ if (dfnMap.get(vertex) === lowMap.get(vertex)) {
7252
+ const SCC = [];
7253
+ let poppedVertex;
7254
+ do {
7255
+ poppedVertex = stack.pop();
7256
+ inStack.delete(poppedVertex);
7257
+ SCC.push(poppedVertex);
7258
+ } while (poppedVertex !== vertex);
7259
+ SCCs.set(SCCs.size, SCC);
7260
+ }
7261
+ };
7262
+ for (const vertex of this.vertexMap.values()) {
7263
+ if (!dfnMap.has(vertex)) {
7264
+ dfs(vertex);
7265
+ }
7266
+ }
7267
+ return { dfnMap, lowMap, SCCs };
7268
+ }
7269
+ /**
7270
+ * Time Complexity: O(V + E) - Depends on the implementation (Tarjan's algorithm).
7271
+ * Space Complexity: O(V) - Depends on the implementation (Tarjan's algorithm).
7272
+ */
7273
+ /**
7274
+ * Time Complexity: O(V + E) - Depends on the implementation (Tarjan's algorithm).
7275
+ * Space Complexity: O(V) - Depends on the implementation (Tarjan's algorithm).
7276
+ *
7277
+ * The function returns a map that associates each vertex object with its corresponding depth-first
7278
+ * number.
7279
+ * @returns A Map object with keys of type VO and values of type number.
7280
+ */
7281
+ getDFNMap() {
7282
+ return this.tarjan().dfnMap;
7283
+ }
7284
+ /**
7285
+ * The function returns a Map object that contains the low values of each vertex in a Tarjan
7286
+ * algorithm.
7287
+ * @returns The method `getLowMap()` is returning a `Map` object with keys of type `VO` and values of
7288
+ * type `number`.
7289
+ */
7290
+ getLowMap() {
7291
+ return this.tarjan().lowMap;
7292
+ }
7293
+ /**
7294
+ * The function "getSCCs" returns a map of strongly connected components (SCCs) using the Tarjan
7295
+ * algorithm.
7296
+ * @returns a map where the keys are numbers and the values are arrays of VO objects.
7297
+ */
7298
+ getSCCs() {
7299
+ return this.tarjan().SCCs;
7300
+ }
7026
7301
  /**
7027
7302
  * Time Complexity: O(1)
7028
7303
  * Space Complexity: O(1)
@@ -7089,8 +7364,8 @@ var dataStructureTyped = (() => {
7089
7364
  */
7090
7365
  constructor(v1, v2, weight, value) {
7091
7366
  super(weight, value);
7092
- __publicField(this, "vertexMap");
7093
- this.vertexMap = [v1, v2];
7367
+ __publicField(this, "endpoints");
7368
+ this.endpoints = [v1, v2];
7094
7369
  }
7095
7370
  };
7096
7371
  var UndirectedGraph = class _UndirectedGraph extends AbstractGraph {
@@ -7141,7 +7416,7 @@ var dataStructureTyped = (() => {
7141
7416
  * Time Complexity: O(|E|), where |E| is the number of edgeMap incident to the given vertex.
7142
7417
  * Space Complexity: O(1)
7143
7418
  *
7144
- * The function `getEdge` returns the first edge that connects two vertexMap, or undefined if no such edge exists.
7419
+ * The function `getEdge` returns the first edge that connects two endpoints, or undefined if no such edge exists.
7145
7420
  * @param {VO | VertexKey | undefined} v1 - The parameter `v1` represents a vertex or vertex ID. It can be of type `VO` (vertex
7146
7421
  * object), `undefined`, or `VertexKey` (a string or number representing the ID of a vertex).
7147
7422
  * @param {VO | VertexKey | undefined} v2 - The parameter `v2` represents a vertex or vertex ID. It can be of type `VO` (vertex
@@ -7155,7 +7430,7 @@ var dataStructureTyped = (() => {
7155
7430
  const vertex1 = this._getVertex(v1);
7156
7431
  const vertex2 = this._getVertex(v2);
7157
7432
  if (vertex1 && vertex2) {
7158
- edgeMap = (_a = this._edgeMap.get(vertex1)) == null ? void 0 : _a.filter((e) => e.vertexMap.includes(vertex2.key));
7433
+ edgeMap = (_a = this._edgeMap.get(vertex1)) == null ? void 0 : _a.filter((e) => e.endpoints.includes(vertex2.key));
7159
7434
  }
7160
7435
  }
7161
7436
  return edgeMap ? edgeMap[0] || void 0 : void 0;
@@ -7172,7 +7447,7 @@ var dataStructureTyped = (() => {
7172
7447
  * @param {VO | VertexKey} v1 - The parameter `v1` represents either a vertex object (`VO`) or a vertex ID (`VertexKey`).
7173
7448
  * @param {VO | VertexKey} v2 - VO | VertexKey - This parameter can be either a vertex object (VO) or a vertex ID
7174
7449
  * (VertexKey). It represents the second vertex of the edge that needs to be removed.
7175
- * @returns the removed edge (EO) if it exists, or undefined if either of the vertexMap (VO) does not exist.
7450
+ * @returns the removed edge (EO) if it exists, or undefined if either of the endpoints (VO) does not exist.
7176
7451
  */
7177
7452
  deleteEdgeBetween(v1, v2) {
7178
7453
  const vertex1 = this._getVertex(v1);
@@ -7183,11 +7458,11 @@ var dataStructureTyped = (() => {
7183
7458
  const v1Edges = this._edgeMap.get(vertex1);
7184
7459
  let removed = void 0;
7185
7460
  if (v1Edges) {
7186
- removed = arrayRemove(v1Edges, (e) => e.vertexMap.includes(vertex2.key))[0] || void 0;
7461
+ removed = arrayRemove(v1Edges, (e) => e.endpoints.includes(vertex2.key))[0] || void 0;
7187
7462
  }
7188
7463
  const v2Edges = this._edgeMap.get(vertex2);
7189
7464
  if (v2Edges) {
7190
- arrayRemove(v2Edges, (e) => e.vertexMap.includes(vertex1.key));
7465
+ arrayRemove(v2Edges, (e) => e.endpoints.includes(vertex1.key));
7191
7466
  }
7192
7467
  return removed;
7193
7468
  }
@@ -7199,7 +7474,7 @@ var dataStructureTyped = (() => {
7199
7474
  * Time Complexity: O(E), where E is the number of edgeMap incident to the given vertex.
7200
7475
  * Space Complexity: O(1)
7201
7476
  *
7202
- * The function `deleteEdge` deletes an edge between two vertexMap in a graph.
7477
+ * The function `deleteEdge` deletes an edge between two endpoints in a graph.
7203
7478
  * @param {EO | VertexKey} edgeOrOneSideVertexKey - The parameter `edgeOrOneSideVertexKey` can be
7204
7479
  * either an edge object or a vertex key.
7205
7480
  * @param {VertexKey} [otherSideVertexKey] - The parameter `otherSideVertexKey` is an optional
@@ -7218,8 +7493,8 @@ var dataStructureTyped = (() => {
7218
7493
  return;
7219
7494
  }
7220
7495
  } else {
7221
- oneSide = this._getVertex(edgeOrOneSideVertexKey.vertexMap[0]);
7222
- otherSide = this._getVertex(edgeOrOneSideVertexKey.vertexMap[1]);
7496
+ oneSide = this._getVertex(edgeOrOneSideVertexKey.endpoints[0]);
7497
+ otherSide = this._getVertex(edgeOrOneSideVertexKey.endpoints[1]);
7223
7498
  }
7224
7499
  if (oneSide && otherSide) {
7225
7500
  return this.deleteEdgeBetween(oneSide, otherSide);
@@ -7256,7 +7531,7 @@ var dataStructureTyped = (() => {
7256
7531
  const neighborEdges = this._edgeMap.get(neighbor);
7257
7532
  if (neighborEdges) {
7258
7533
  const restEdges = neighborEdges.filter((edge) => {
7259
- return !edge.vertexMap.includes(vertexKey);
7534
+ return !edge.endpoints.includes(vertexKey);
7260
7535
  });
7261
7536
  this._edgeMap.set(neighbor, restEdges);
7262
7537
  }
@@ -7337,7 +7612,7 @@ var dataStructureTyped = (() => {
7337
7612
  * Time Complexity: O(|V| + |E|), where |V| is the number of vertexMap and |E| is the number of edgeMap.
7338
7613
  * Space Complexity: O(|E|)
7339
7614
  *
7340
- * The function "getNeighbors" returns an array of neighboring vertexMap for a given vertex or vertex ID.
7615
+ * The function "getNeighbors" returns an array of neighboring endpoints for a given vertex or vertex ID.
7341
7616
  * @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`VO`) or a vertex ID
7342
7617
  * (`VertexKey`).
7343
7618
  * @returns an array of vertexMap (VO[]).
@@ -7348,7 +7623,7 @@ var dataStructureTyped = (() => {
7348
7623
  if (vertex) {
7349
7624
  const neighborEdges = this.edgesOf(vertex);
7350
7625
  for (const edge of neighborEdges) {
7351
- const neighbor = this._getVertex(edge.vertexMap.filter((e) => e !== vertex.key)[0]);
7626
+ const neighbor = this._getVertex(edge.endpoints.filter((e) => e !== vertex.key)[0]);
7352
7627
  if (neighbor) {
7353
7628
  neighbors.push(neighbor);
7354
7629
  }
@@ -7364,18 +7639,18 @@ var dataStructureTyped = (() => {
7364
7639
  * Time Complexity: O(1)
7365
7640
  * Space Complexity: O(1)
7366
7641
  *
7367
- * The function "getEndsOfEdge" returns the vertexMap at the ends of an edge if the edge exists in the graph, otherwise
7642
+ * The function "getEndsOfEdge" returns the endpoints at the ends of an edge if the edge exists in the graph, otherwise
7368
7643
  * it returns undefined.
7369
7644
  * @param {EO} edge - The parameter "edge" is of type EO, which represents an edge in a graph.
7370
- * @returns The function `getEndsOfEdge` returns an array containing two vertexMap `[VO, VO]` if the edge exists in the
7645
+ * @returns The function `getEndsOfEdge` returns an array containing two endpoints `[VO, VO]` if the edge exists in the
7371
7646
  * graph. If the edge does not exist, it returns `undefined`.
7372
7647
  */
7373
7648
  getEndsOfEdge(edge) {
7374
- if (!this.hasEdge(edge.vertexMap[0], edge.vertexMap[1])) {
7649
+ if (!this.hasEdge(edge.endpoints[0], edge.endpoints[1])) {
7375
7650
  return void 0;
7376
7651
  }
7377
- const v1 = this._getVertex(edge.vertexMap[0]);
7378
- const v2 = this._getVertex(edge.vertexMap[1]);
7652
+ const v1 = this._getVertex(edge.endpoints[0]);
7653
+ const v2 = this._getVertex(edge.endpoints[1]);
7379
7654
  if (v1 && v2) {
7380
7655
  return [v1, v2];
7381
7656
  } else {
@@ -7389,6 +7664,20 @@ var dataStructureTyped = (() => {
7389
7664
  isEmpty() {
7390
7665
  return this.vertexMap.size === 0 && this.edgeMap.size === 0;
7391
7666
  }
7667
+ /**
7668
+ * Time Complexity: O(1)
7669
+ * Space Complexity: O(1)
7670
+ */
7671
+ /**
7672
+ * Time Complexity: O(1)
7673
+ * Space Complexity: O(1)
7674
+ *
7675
+ * The clear function resets the vertex and edge maps to empty maps.
7676
+ */
7677
+ clear() {
7678
+ this._vertexMap = /* @__PURE__ */ new Map();
7679
+ this._edgeMap = /* @__PURE__ */ new Map();
7680
+ }
7392
7681
  /**
7393
7682
  * The clone function creates a new UndirectedGraph object and copies the
7394
7683
  * vertexMap and edgeMap from this graph to the new one. This is done by
@@ -7408,6 +7697,96 @@ var dataStructureTyped = (() => {
7408
7697
  * Time Complexity: O(1)
7409
7698
  * Space Complexity: O(1)
7410
7699
  */
7700
+ /**
7701
+ * Time Complexity: O(V + E)
7702
+ * Space Complexity: O(V)
7703
+ * Tarjan is an algorithm based on dfs,which is used to solve the connectivity problem of graphs.
7704
+ * 1. Tarjan can find the articulation points and bridges(critical edgeMap) of undirected graphs in linear time
7705
+ *
7706
+ * The function `tarjan` implements the Tarjan's algorithm to find bridges and cut vertices in a
7707
+ * graph.
7708
+ * @returns The function `tarjan()` returns an object with the following properties:
7709
+ */
7710
+ tarjan() {
7711
+ const dfnMap = /* @__PURE__ */ new Map();
7712
+ const lowMap = /* @__PURE__ */ new Map();
7713
+ const bridges = [];
7714
+ const cutVertices = [];
7715
+ let time = 0;
7716
+ const dfs = (vertex, parent) => {
7717
+ dfnMap.set(vertex, time);
7718
+ lowMap.set(vertex, time);
7719
+ time++;
7720
+ const neighbors = this.getNeighbors(vertex);
7721
+ let childCount = 0;
7722
+ for (const neighbor of neighbors) {
7723
+ if (!dfnMap.has(neighbor)) {
7724
+ childCount++;
7725
+ dfs(neighbor, vertex);
7726
+ lowMap.set(vertex, Math.min(lowMap.get(vertex), lowMap.get(neighbor)));
7727
+ if (lowMap.get(neighbor) > dfnMap.get(vertex)) {
7728
+ const edge = this.getEdge(vertex, neighbor);
7729
+ if (edge) {
7730
+ bridges.push(edge);
7731
+ }
7732
+ }
7733
+ if (parent !== void 0 && lowMap.get(neighbor) >= dfnMap.get(vertex)) {
7734
+ cutVertices.push(vertex);
7735
+ }
7736
+ } else if (neighbor !== parent) {
7737
+ lowMap.set(vertex, Math.min(lowMap.get(vertex), dfnMap.get(neighbor)));
7738
+ }
7739
+ }
7740
+ if (parent === void 0 && childCount > 1) {
7741
+ cutVertices.push(vertex);
7742
+ }
7743
+ };
7744
+ for (const vertex of this.vertexMap.values()) {
7745
+ if (!dfnMap.has(vertex)) {
7746
+ dfs(vertex, void 0);
7747
+ }
7748
+ }
7749
+ return {
7750
+ dfnMap,
7751
+ lowMap,
7752
+ bridges,
7753
+ cutVertices
7754
+ };
7755
+ }
7756
+ /**
7757
+ * Time Complexity: O(V + E)
7758
+ * Space Complexity: O(V)
7759
+ * Tarjan is an algorithm based on dfs,which is used to solve the connectivity problem of graphs.
7760
+ * 1. Tarjan can find the articulation points and bridges(critical edgeMap) of undirected graphs in linear time
7761
+ */
7762
+ /**
7763
+ * The function "getBridges" returns an array of bridges in a graph using the Tarjan's algorithm.
7764
+ * @returns The function `getBridges()` is returning the bridges found using the Tarjan's algorithm.
7765
+ */
7766
+ getBridges() {
7767
+ return this.tarjan().bridges;
7768
+ }
7769
+ /**
7770
+ * The function "getCutVertices" returns an array of cut vertices using the Tarjan's algorithm.
7771
+ * @returns the cut vertices found using the Tarjan's algorithm.
7772
+ */
7773
+ getCutVertices() {
7774
+ return this.tarjan().cutVertices;
7775
+ }
7776
+ /**
7777
+ * The function returns the dfnMap property of the result of the tarjan() function.
7778
+ * @returns the `dfnMap` property of the result of calling the `tarjan()` function.
7779
+ */
7780
+ getDFNMap() {
7781
+ return this.tarjan().dfnMap;
7782
+ }
7783
+ /**
7784
+ * The function returns the lowMap property of the result of the tarjan() function.
7785
+ * @returns the lowMap property of the result of calling the tarjan() function.
7786
+ */
7787
+ getLowMap() {
7788
+ return this.tarjan().lowMap;
7789
+ }
7411
7790
  /**
7412
7791
  * Time Complexity: O(1)
7413
7792
  * Space Complexity: O(1)
@@ -7417,7 +7796,7 @@ var dataStructureTyped = (() => {
7417
7796
  * @returns a boolean value.
7418
7797
  */
7419
7798
  _addEdge(edge) {
7420
- for (const end of edge.vertexMap) {
7799
+ for (const end of edge.endpoints) {
7421
7800
  const endVertex = this._getVertex(end);
7422
7801
  if (endVertex === void 0)
7423
7802
  return false;
@@ -7579,7 +7958,7 @@ var dataStructureTyped = (() => {
7579
7958
  /**
7580
7959
  * The constructor function initializes an object with a key and an optional value.
7581
7960
  * @param {K} key - The "key" parameter is of type K, which represents the type of the key for the
7582
- * constructor. It is used to set the value of the "key" property of the object being created.
7961
+ * constructor. It is used to set the key property of the object being created.
7583
7962
  * @param {V} [value] - The "value" parameter is an optional parameter of type V. It represents the
7584
7963
  * value associated with the key in the constructor.
7585
7964
  */
@@ -9263,18 +9642,37 @@ var dataStructureTyped = (() => {
9263
9642
  this._left = void 0;
9264
9643
  this._right = void 0;
9265
9644
  }
9645
+ /**
9646
+ * The function returns the value of the `_left` property.
9647
+ * @returns The `_left` property of the current object is being returned.
9648
+ */
9266
9649
  get left() {
9267
9650
  return this._left;
9268
9651
  }
9652
+ /**
9653
+ * The function sets the left child of a node and updates the parent reference of the child.
9654
+ * @param {NODE | undefined} v - The parameter `v` is of type `NODE | undefined`. It can either be an
9655
+ * instance of the `NODE` class or `undefined`.
9656
+ */
9269
9657
  set left(v) {
9270
9658
  if (v) {
9271
9659
  v.parent = this;
9272
9660
  }
9273
9661
  this._left = v;
9274
9662
  }
9663
+ /**
9664
+ * The function returns the right node of a binary tree or undefined if there is no right node.
9665
+ * @returns The method is returning the value of the `_right` property, which is of type `NODE` or
9666
+ * `undefined`.
9667
+ */
9275
9668
  get right() {
9276
9669
  return this._right;
9277
9670
  }
9671
+ /**
9672
+ * The function sets the right child of a node and updates the parent reference of the child.
9673
+ * @param {NODE | undefined} v - The parameter `v` is of type `NODE | undefined`. It can either be a
9674
+ * `NODE` object or `undefined`.
9675
+ */
9278
9676
  set right(v) {
9279
9677
  if (v) {
9280
9678
  v.parent = this;
@@ -9284,10 +9682,10 @@ var dataStructureTyped = (() => {
9284
9682
  };
9285
9683
  var BST = class _BST extends BinaryTree {
9286
9684
  /**
9287
- * This is the constructor function for a binary search tree class in TypeScript, which initializes
9288
- * the tree with optional keysOrNodesOrEntries and options.
9289
- * @param [keysOrNodesOrEntries] - An optional iterable of KeyOrNodeOrEntry objects that will be added to the
9290
- * binary search tree.
9685
+ * This is the constructor function for a TypeScript class that initializes a binary search tree with
9686
+ * optional keys or nodes or entries and options.
9687
+ * @param keysOrNodesOrEntries - An iterable object that contains keys, nodes, or entries. It is used
9688
+ * to initialize the binary search tree with the provided keys, nodes, or entries.
9291
9689
  * @param [options] - The `options` parameter is an optional object that can contain additional
9292
9690
  * configuration options for the binary search tree. It can have the following properties:
9293
9691
  */
@@ -9304,19 +9702,27 @@ var dataStructureTyped = (() => {
9304
9702
  if (keysOrNodesOrEntries)
9305
9703
  this.addMany(keysOrNodesOrEntries);
9306
9704
  }
9705
+ /**
9706
+ * The function returns the root node of a tree structure.
9707
+ * @returns The `_root` property of the object, which is of type `NODE` or `undefined`.
9708
+ */
9307
9709
  get root() {
9308
9710
  return this._root;
9309
9711
  }
9712
+ /**
9713
+ * The function returns the value of the _variant property.
9714
+ * @returns The value of the `_variant` property.
9715
+ */
9310
9716
  get variant() {
9311
9717
  return this._variant;
9312
9718
  }
9313
9719
  /**
9314
- * The function creates a new binary search tree node with the given key and value.
9315
- * @param {K} key - The key parameter is the key value that will be associated with
9316
- * the new node. It is used to determine the position of the node in the binary search tree.
9317
- * @param [value] - The parameter `value` is an optional value that can be assigned to the node. It
9318
- * represents the value associated with the node in a binary search tree.
9319
- * @returns a new instance of the BSTNode class with the specified key and value.
9720
+ * The function creates a new BSTNode with the given key and value and returns it.
9721
+ * @param {K} key - The key parameter is of type K, which represents the type of the key for the node
9722
+ * being created.
9723
+ * @param {V} [value] - The "value" parameter is an optional parameter of type V. It represents the
9724
+ * value associated with the key in the node being created.
9725
+ * @returns The method is returning a new instance of the BSTNode class, casted as the NODE type.
9320
9726
  */
9321
9727
  createNode(key, value) {
9322
9728
  return new BSTNode(key, value);
@@ -9324,9 +9730,10 @@ var dataStructureTyped = (() => {
9324
9730
  /**
9325
9731
  * The function creates a new binary search tree with the specified options.
9326
9732
  * @param [options] - The `options` parameter is an optional object that allows you to customize the
9327
- * behavior of the `createTree` method. It accepts a partial `BSTOptions` object, which is a type
9328
- * that defines various options for creating a binary search tree.
9329
- * @returns a new instance of the BST class with the specified options.
9733
+ * behavior of the `createTree` method. It is of type `Partial<BSTOptions<K>>`, which means it is a
9734
+ * partial object of type `BSTOptions<K>`.
9735
+ * @returns a new instance of the BST class, with the provided options merged with the default
9736
+ * options. The returned value is casted as TREE.
9330
9737
  */
9331
9738
  createTree(options) {
9332
9739
  return new _BST([], __spreadValues({
@@ -9816,11 +10223,9 @@ var dataStructureTyped = (() => {
9816
10223
  const compared = this._compare(cur.key, targetKey);
9817
10224
  if (compared === lesserOrGreater)
9818
10225
  ans.push(callback(cur));
9819
- if (!cur.left && !cur.right)
9820
- return;
9821
- if (cur.left && this._compare(cur.left.key, targetKey) === lesserOrGreater)
10226
+ if (this.isRealNode(cur.left))
9822
10227
  _traverse(cur.left);
9823
- if (cur.right && this._compare(cur.right.key, targetKey) === lesserOrGreater)
10228
+ if (this.isRealNode(cur.right))
9824
10229
  _traverse(cur.right);
9825
10230
  };
9826
10231
  _traverse(this.root);
@@ -9829,13 +10234,13 @@ var dataStructureTyped = (() => {
9829
10234
  const queue = new Queue([this.root]);
9830
10235
  while (queue.size > 0) {
9831
10236
  const cur = queue.shift();
9832
- if (cur) {
10237
+ if (this.isRealNode(cur)) {
9833
10238
  const compared = this._compare(cur.key, targetKey);
9834
10239
  if (compared === lesserOrGreater)
9835
10240
  ans.push(callback(cur));
9836
- if (cur.left && this._compare(cur.left.key, targetKey) === lesserOrGreater)
10241
+ if (this.isRealNode(cur.left))
9837
10242
  queue.push(cur.left);
9838
- if (cur.right && this._compare(cur.right.key, targetKey) === lesserOrGreater)
10243
+ if (this.isRealNode(cur.right))
9839
10244
  queue.push(cur.right);
9840
10245
  }
9841
10246
  }
@@ -9957,6 +10362,11 @@ var dataStructureTyped = (() => {
9957
10362
  }
9958
10363
  return balanced;
9959
10364
  }
10365
+ /**
10366
+ * The function sets the root property of an object and updates the parent property of the new root.
10367
+ * @param {NODE | undefined} v - The parameter `v` is of type `NODE | undefined`. This means that it
10368
+ * can either be an object of type `NODE` or it can be `undefined`.
10369
+ */
9960
10370
  _setRoot(v) {
9961
10371
  if (v) {
9962
10372
  v.parent = void 0;
@@ -9999,18 +10409,40 @@ var dataStructureTyped = (() => {
9999
10409
  this._msb = getMSB(max);
10000
10410
  this._negativeCount = frequency < 0 ? max : 0;
10001
10411
  }
10412
+ /**
10413
+ * The function returns the frequency map of numbers.
10414
+ * @returns The `_freqMap` property, which is a record with number keys and number values, is being
10415
+ * returned.
10416
+ */
10002
10417
  get freqMap() {
10003
10418
  return this._freqMap;
10004
10419
  }
10420
+ /**
10421
+ * The function returns the value of the _msb property.
10422
+ * @returns The `_msb` property of the object.
10423
+ */
10005
10424
  get msb() {
10006
10425
  return this._msb;
10007
10426
  }
10427
+ /**
10428
+ * The function returns the value of the _negativeCount property.
10429
+ * @returns The method is returning the value of the variable `_negativeCount`, which is of type
10430
+ * `number`.
10431
+ */
10008
10432
  get negativeCount() {
10009
10433
  return this._negativeCount;
10010
10434
  }
10435
+ /**
10436
+ * The above function returns the value of the protected variable `_freq`.
10437
+ * @returns The frequency value stored in the protected variable `_freq`.
10438
+ */
10011
10439
  get freq() {
10012
10440
  return this._freq;
10013
10441
  }
10442
+ /**
10443
+ * The above function returns the maximum value.
10444
+ * @returns The maximum value stored in the variable `_max`.
10445
+ */
10014
10446
  get max() {
10015
10447
  return this._max;
10016
10448
  }
@@ -10243,60 +10675,177 @@ var dataStructureTyped = (() => {
10243
10675
 
10244
10676
  // src/data-structures/binary-tree/segment-tree.ts
10245
10677
  var SegmentTreeNode = class {
10246
- constructor(start, end, sum, value) {
10247
- __publicField(this, "start", 0);
10248
- __publicField(this, "end", 0);
10249
- __publicField(this, "value");
10250
- __publicField(this, "sum", 0);
10251
- __publicField(this, "left");
10252
- __publicField(this, "right");
10253
- this.start = start;
10254
- this.end = end;
10255
- this.sum = sum;
10256
- this.value = value || void 0;
10257
- }
10258
- };
10259
- var SegmentTree = class {
10260
10678
  /**
10261
- * The constructor initializes the values, start, end, and root properties of an object.
10262
- * @param {number[]} values - An array of numbers that will be used to build a binary search tree.
10263
- * @param {number} [start] - The `start` parameter is the index of the first element in the `values` array that should
10264
- * be included in the range. If no value is provided for `start`, it defaults to 0, which means the range starts from
10265
- * the beginning of the array.
10266
- * @param {number} [end] - The "end" parameter is the index of the last element in the "values" array that should be
10267
- * included in the range. If not provided, it defaults to the index of the last element in the "values" array.
10679
+ * The constructor initializes the properties of a SegmentTreeNode object.
10680
+ * @param {number} start - The `start` parameter represents the starting index of the segment covered
10681
+ * by this node in a segment tree.
10682
+ * @param {number} end - The `end` parameter represents the end index of the segment covered by this
10683
+ * node in a segment tree.
10684
+ * @param {number} sum - The `sum` parameter represents the sum of the values in the range covered by
10685
+ * the segment tree node.
10686
+ * @param {SegmentTreeNodeVal | undefined} [value] - The `value` parameter is an optional parameter
10687
+ * of type `SegmentTreeNodeVal`. It represents the value associated with the segment tree node.
10268
10688
  */
10269
- constructor(values, start, end) {
10270
- __publicField(this, "_values", []);
10689
+ constructor(start, end, sum, value) {
10271
10690
  __publicField(this, "_start", 0);
10272
- __publicField(this, "_end");
10273
- __publicField(this, "_root");
10274
- start = start || 0;
10275
- end = end || values.length - 1;
10276
- this._values = values;
10691
+ __publicField(this, "_end", 0);
10692
+ __publicField(this, "_value");
10693
+ __publicField(this, "_sum", 0);
10694
+ __publicField(this, "_left");
10695
+ __publicField(this, "_right");
10277
10696
  this._start = start;
10278
10697
  this._end = end;
10279
- if (values.length > 0) {
10280
- this._root = this.build(start, end);
10281
- } else {
10282
- this._root = void 0;
10283
- this._values = [];
10284
- }
10285
- }
10286
- get values() {
10287
- return this._values;
10698
+ this._sum = sum;
10699
+ this._value = value || void 0;
10288
10700
  }
10701
+ /**
10702
+ * The function returns the value of the protected variable _start.
10703
+ * @returns The start value, which is of type number.
10704
+ */
10289
10705
  get start() {
10290
10706
  return this._start;
10291
10707
  }
10708
+ /**
10709
+ * The above function sets the value of the "start" property.
10710
+ * @param {number} value - The value parameter is of type number.
10711
+ */
10712
+ set start(value) {
10713
+ this._start = value;
10714
+ }
10715
+ /**
10716
+ * The function returns the value of the protected variable `_end`.
10717
+ * @returns The value of the protected property `_end`.
10718
+ */
10292
10719
  get end() {
10293
10720
  return this._end;
10294
10721
  }
10295
- get root() {
10296
- return this._root;
10722
+ /**
10723
+ * The above function sets the value of the "end" property.
10724
+ * @param {number} value - The value parameter is a number that represents the new value for the end
10725
+ * property.
10726
+ */
10727
+ set end(value) {
10728
+ this._end = value;
10297
10729
  }
10298
10730
  /**
10299
- * The build function creates a segment tree by recursively dividing the given range into smaller segments and assigning
10731
+ * The function returns the value of a segment tree node.
10732
+ * @returns The value being returned is either a `SegmentTreeNodeVal` object or `undefined`.
10733
+ */
10734
+ get value() {
10735
+ return this._value;
10736
+ }
10737
+ /**
10738
+ * The function sets the value of a segment tree node.
10739
+ * @param {SegmentTreeNodeVal | undefined} value - The `value` parameter is of type
10740
+ * `SegmentTreeNodeVal` or `undefined`.
10741
+ */
10742
+ set value(value) {
10743
+ this._value = value;
10744
+ }
10745
+ /**
10746
+ * The function returns the value of the sum property.
10747
+ * @returns The method is returning the value of the variable `_sum`.
10748
+ */
10749
+ get sum() {
10750
+ return this._sum;
10751
+ }
10752
+ /**
10753
+ * The above function sets the value of the sum property.
10754
+ * @param {number} value - The parameter "value" is of type "number".
10755
+ */
10756
+ set sum(value) {
10757
+ this._sum = value;
10758
+ }
10759
+ /**
10760
+ * The function returns the left child of a segment tree node.
10761
+ * @returns The `left` property of the `SegmentTreeNode` object is being returned. It is of type
10762
+ * `SegmentTreeNode` or `undefined`.
10763
+ */
10764
+ get left() {
10765
+ return this._left;
10766
+ }
10767
+ /**
10768
+ * The function sets the value of the left property of a SegmentTreeNode object.
10769
+ * @param {SegmentTreeNode | undefined} value - The value parameter is of type SegmentTreeNode or
10770
+ * undefined.
10771
+ */
10772
+ set left(value) {
10773
+ this._left = value;
10774
+ }
10775
+ /**
10776
+ * The function returns the right child of a segment tree node.
10777
+ * @returns The `getRight()` method is returning a value of type `SegmentTreeNode` or `undefined`.
10778
+ */
10779
+ get right() {
10780
+ return this._right;
10781
+ }
10782
+ /**
10783
+ * The function sets the right child of a segment tree node.
10784
+ * @param {SegmentTreeNode | undefined} value - The `value` parameter is of type `SegmentTreeNode |
10785
+ * undefined`. This means that it can accept either a `SegmentTreeNode` object or `undefined` as its
10786
+ * value.
10787
+ */
10788
+ set right(value) {
10789
+ this._right = value;
10790
+ }
10791
+ };
10792
+ var SegmentTree = class {
10793
+ /**
10794
+ * The constructor initializes the values, start, end, and root properties of an object.
10795
+ * @param {number[]} values - An array of numbers that will be used to build a binary search tree.
10796
+ * @param {number} [start] - The `start` parameter is the index of the first element in the `values` array that should
10797
+ * be included in the range. If no value is provided for `start`, it defaults to 0, which means the range starts from
10798
+ * the beginning of the array.
10799
+ * @param {number} [end] - The "end" parameter is the index of the last element in the "values" array that should be
10800
+ * included in the range. If not provided, it defaults to the index of the last element in the "values" array.
10801
+ */
10802
+ constructor(values, start, end) {
10803
+ __publicField(this, "_values", []);
10804
+ __publicField(this, "_start", 0);
10805
+ __publicField(this, "_end");
10806
+ __publicField(this, "_root");
10807
+ start = start || 0;
10808
+ end = end || values.length - 1;
10809
+ this._values = values;
10810
+ this._start = start;
10811
+ this._end = end;
10812
+ if (values.length > 0) {
10813
+ this._root = this.build(start, end);
10814
+ } else {
10815
+ this._root = void 0;
10816
+ this._values = [];
10817
+ }
10818
+ }
10819
+ /**
10820
+ * The function returns an array of numbers.
10821
+ * @returns An array of numbers is being returned.
10822
+ */
10823
+ get values() {
10824
+ return this._values;
10825
+ }
10826
+ /**
10827
+ * The function returns the value of the protected variable _start.
10828
+ * @returns The start value, which is of type number.
10829
+ */
10830
+ get start() {
10831
+ return this._start;
10832
+ }
10833
+ /**
10834
+ * The function returns the value of the protected variable `_end`.
10835
+ * @returns The value of the protected property `_end`.
10836
+ */
10837
+ get end() {
10838
+ return this._end;
10839
+ }
10840
+ /**
10841
+ * The function returns the root node of a segment tree.
10842
+ * @returns The `root` property of the class `SegmentTreeNode` or `undefined` if it is not defined.
10843
+ */
10844
+ get root() {
10845
+ return this._root;
10846
+ }
10847
+ /**
10848
+ * The build function creates a segment tree by recursively dividing the given range into smaller segments and assigning
10300
10849
  * the sum of values to each segment.
10301
10850
  * @param {number} start - The `start` parameter represents the starting index of the segment or range for which we are
10302
10851
  * building the segment tree.
@@ -10407,10 +10956,33 @@ var dataStructureTyped = (() => {
10407
10956
 
10408
10957
  // src/data-structures/binary-tree/avl-tree.ts
10409
10958
  var AVLTreeNode = class extends BSTNode {
10959
+ /**
10960
+ * The constructor function initializes a new instance of a class with a key and an optional value,
10961
+ * and sets the height property to 0.
10962
+ * @param {K} key - The "key" parameter is of type K, which represents the type of the key for the
10963
+ * constructor. It is used to initialize the key property of the object being created.
10964
+ * @param {V} [value] - The "value" parameter is an optional parameter of type V. It represents the
10965
+ * value associated with the key in the constructor.
10966
+ */
10410
10967
  constructor(key, value) {
10411
10968
  super(key, value);
10412
- __publicField(this, "height");
10413
- this.height = 0;
10969
+ __publicField(this, "_height");
10970
+ this._height = 0;
10971
+ }
10972
+ /**
10973
+ * The function returns the value of the height property.
10974
+ * @returns The height of the object.
10975
+ */
10976
+ get height() {
10977
+ return this._height;
10978
+ }
10979
+ /**
10980
+ * The above function sets the value of the height property.
10981
+ * @param {number} value - The value parameter is a number that represents the new height value to be
10982
+ * set.
10983
+ */
10984
+ set height(value) {
10985
+ this._height = value;
10414
10986
  }
10415
10987
  };
10416
10988
  var AVLTree = class _AVLTree extends BST {
@@ -10817,6 +11389,15 @@ var dataStructureTyped = (() => {
10817
11389
  }
10818
11390
  }
10819
11391
  }
11392
+ /**
11393
+ * The function replaces an old node with a new node while preserving the height of the old node.
11394
+ * @param {NODE} oldNode - The `oldNode` parameter is the node that you want to replace with the
11395
+ * `newNode`.
11396
+ * @param {NODE} newNode - The `newNode` parameter is the new node that will replace the `oldNode` in
11397
+ * the data structure.
11398
+ * @returns the result of calling the `_replaceNode` method on the superclass, passing in the
11399
+ * `oldNode` and `newNode` as arguments.
11400
+ */
10820
11401
  _replaceNode(oldNode, newNode) {
10821
11402
  newNode.height = oldNode.height;
10822
11403
  return super._replaceNode(oldNode, newNode);
@@ -10825,10 +11406,35 @@ var dataStructureTyped = (() => {
10825
11406
 
10826
11407
  // src/data-structures/binary-tree/rb-tree.ts
10827
11408
  var RedBlackTreeNode = class extends BSTNode {
11409
+ /**
11410
+ * The constructor function initializes a Red-Black Tree Node with a key, an optional value, and a
11411
+ * color.
11412
+ * @param {K} key - The key parameter is of type K and represents the key of the node in the
11413
+ * Red-Black Tree.
11414
+ * @param {V} [value] - The `value` parameter is an optional parameter that represents the value
11415
+ * associated with the key in the Red-Black Tree Node. It is not required and can be omitted when
11416
+ * creating a new instance of the Red-Black Tree Node.
11417
+ * @param {RBTNColor} color - The `color` parameter is used to specify the color of the Red-Black
11418
+ * Tree Node. It is an optional parameter with a default value of `RBTNColor.BLACK`.
11419
+ */
10828
11420
  constructor(key, value, color = 0 /* BLACK */) {
10829
11421
  super(key, value);
10830
- __publicField(this, "color");
10831
- this.color = color;
11422
+ __publicField(this, "_color");
11423
+ this._color = color;
11424
+ }
11425
+ /**
11426
+ * The function returns the color value of a variable.
11427
+ * @returns The color value stored in the protected variable `_color`.
11428
+ */
11429
+ get color() {
11430
+ return this._color;
11431
+ }
11432
+ /**
11433
+ * The function sets the color property to the specified value.
11434
+ * @param {RBTNColor} value - The value parameter is of type RBTNColor.
11435
+ */
11436
+ set color(value) {
11437
+ this._color = value;
10832
11438
  }
10833
11439
  };
10834
11440
  var RedBlackTree = class _RedBlackTree extends BST {
@@ -10845,16 +11451,31 @@ var dataStructureTyped = (() => {
10845
11451
  */
10846
11452
  constructor(keysOrNodesOrEntries = [], options) {
10847
11453
  super([], options);
10848
- __publicField(this, "Sentinel", new RedBlackTreeNode(NaN));
11454
+ __publicField(this, "_Sentinel", new RedBlackTreeNode(NaN));
10849
11455
  __publicField(this, "_root");
10850
11456
  __publicField(this, "_size", 0);
10851
- this._root = this.Sentinel;
11457
+ this._root = this._Sentinel;
10852
11458
  if (keysOrNodesOrEntries)
10853
11459
  super.addMany(keysOrNodesOrEntries);
10854
11460
  }
11461
+ /**
11462
+ * The function returns the value of the `_Sentinel` property.
11463
+ * @returns The method is returning the value of the `_Sentinel` property.
11464
+ */
11465
+ get Sentinel() {
11466
+ return this._Sentinel;
11467
+ }
11468
+ /**
11469
+ * The function returns the root node.
11470
+ * @returns The root node of the data structure.
11471
+ */
10855
11472
  get root() {
10856
11473
  return this._root;
10857
11474
  }
11475
+ /**
11476
+ * The function returns the size of an object.
11477
+ * @returns The size of the object, which is a number.
11478
+ */
10858
11479
  get size() {
10859
11480
  return this._size;
10860
11481
  }
@@ -10922,8 +11543,14 @@ var dataStructureTyped = (() => {
10922
11543
  isNode(keyOrNodeOrEntry) {
10923
11544
  return keyOrNodeOrEntry instanceof RedBlackTreeNode;
10924
11545
  }
11546
+ /**
11547
+ * The function checks if a given node is a real node in a Red-Black Tree.
11548
+ * @param {NODE | undefined} node - The `node` parameter is of type `NODE | undefined`, which means
11549
+ * it can either be of type `NODE` or `undefined`.
11550
+ * @returns a boolean value.
11551
+ */
10925
11552
  isRealNode(node) {
10926
- if (node === this.Sentinel || node === void 0)
11553
+ if (node === this._Sentinel || node === void 0)
10927
11554
  return false;
10928
11555
  return node instanceof RedBlackTreeNode;
10929
11556
  }
@@ -10948,11 +11575,11 @@ var dataStructureTyped = (() => {
10948
11575
  const newNode = this.keyValueOrEntryToNode(keyOrNodeOrEntry, value);
10949
11576
  if (newNode === void 0)
10950
11577
  return false;
10951
- newNode.left = this.Sentinel;
10952
- newNode.right = this.Sentinel;
11578
+ newNode.left = this._Sentinel;
11579
+ newNode.right = this._Sentinel;
10953
11580
  let y = void 0;
10954
11581
  let x = this.root;
10955
- while (x !== this.Sentinel) {
11582
+ while (x !== this._Sentinel) {
10956
11583
  y = x;
10957
11584
  if (x) {
10958
11585
  if (newNode.key < x.key) {
@@ -11012,9 +11639,9 @@ var dataStructureTyped = (() => {
11012
11639
  if (identifier === null)
11013
11640
  return ans;
11014
11641
  const helper = (node) => {
11015
- let z = this.Sentinel;
11642
+ let z = this._Sentinel;
11016
11643
  let x, y;
11017
- while (node !== this.Sentinel) {
11644
+ while (node !== this._Sentinel) {
11018
11645
  if (node && callback(node) === identifier) {
11019
11646
  z = node;
11020
11647
  }
@@ -11024,16 +11651,16 @@ var dataStructureTyped = (() => {
11024
11651
  node = node == null ? void 0 : node.left;
11025
11652
  }
11026
11653
  }
11027
- if (z === this.Sentinel) {
11654
+ if (z === this._Sentinel) {
11028
11655
  this._size--;
11029
11656
  return;
11030
11657
  }
11031
11658
  y = z;
11032
11659
  let yOriginalColor = y.color;
11033
- if (z.left === this.Sentinel) {
11660
+ if (z.left === this._Sentinel) {
11034
11661
  x = z.right;
11035
11662
  this._rbTransplant(z, z.right);
11036
- } else if (z.right === this.Sentinel) {
11663
+ } else if (z.right === this._Sentinel) {
11037
11664
  x = z.left;
11038
11665
  this._rbTransplant(z, z.left);
11039
11666
  } else {
@@ -11097,8 +11724,14 @@ var dataStructureTyped = (() => {
11097
11724
  * Time Complexity: O(1)
11098
11725
  * Space Complexity: O(1)
11099
11726
  */
11727
+ /**
11728
+ * Time Complexity: O(1)
11729
+ * Space Complexity: O(1)
11730
+ *
11731
+ * The "clear" function sets the root node to the sentinel node and resets the size to 0.
11732
+ */
11100
11733
  clear() {
11101
- this._root = this.Sentinel;
11734
+ this._root = this._Sentinel;
11102
11735
  this._size = 0;
11103
11736
  }
11104
11737
  /**
@@ -11125,6 +11758,12 @@ var dataStructureTyped = (() => {
11125
11758
  }
11126
11759
  return y;
11127
11760
  }
11761
+ /**
11762
+ * The function sets the root node of a tree structure and updates the parent property of the new
11763
+ * root node.
11764
+ * @param {NODE} v - The parameter "v" is of type "NODE", which represents a node in a data
11765
+ * structure.
11766
+ */
11128
11767
  _setRoot(v) {
11129
11768
  if (v) {
11130
11769
  v.parent = void 0;
@@ -11146,7 +11785,7 @@ var dataStructureTyped = (() => {
11146
11785
  if (x.right) {
11147
11786
  const y = x.right;
11148
11787
  x.right = y.left;
11149
- if (y.left !== this.Sentinel) {
11788
+ if (y.left !== this._Sentinel) {
11150
11789
  if (y.left)
11151
11790
  y.left.parent = x;
11152
11791
  }
@@ -11178,7 +11817,7 @@ var dataStructureTyped = (() => {
11178
11817
  if (x.left) {
11179
11818
  const y = x.left;
11180
11819
  x.left = y.right;
11181
- if (y.right !== this.Sentinel) {
11820
+ if (y.right !== this._Sentinel) {
11182
11821
  if (y.right)
11183
11822
  y.right.parent = x;
11184
11823
  }
@@ -11208,12 +11847,12 @@ var dataStructureTyped = (() => {
11208
11847
  */
11209
11848
  _fixInsert(k) {
11210
11849
  let u;
11211
- while (k.parent && k.parent.color === 1) {
11850
+ while (k.parent && k.parent.color === 1 /* RED */) {
11212
11851
  if (k.parent.parent && k.parent === k.parent.parent.right) {
11213
11852
  u = k.parent.parent.left;
11214
- if (u && u.color === 1) {
11215
- u.color = 0 /* BLACK */;
11853
+ if (u && u.color === 1 /* RED */) {
11216
11854
  k.parent.color = 0 /* BLACK */;
11855
+ u.color = 0 /* BLACK */;
11217
11856
  k.parent.parent.color = 1 /* RED */;
11218
11857
  k = k.parent.parent;
11219
11858
  } else {
@@ -11221,15 +11860,17 @@ var dataStructureTyped = (() => {
11221
11860
  k = k.parent;
11222
11861
  this._rightRotate(k);
11223
11862
  }
11224
- k.parent.color = 0 /* BLACK */;
11225
- k.parent.parent.color = 1 /* RED */;
11863
+ if (k.parent.color === 1 /* RED */) {
11864
+ k.parent.color = 0 /* BLACK */;
11865
+ k.parent.parent.color = 1 /* RED */;
11866
+ }
11226
11867
  this._leftRotate(k.parent.parent);
11227
11868
  }
11228
11869
  } else {
11229
11870
  u = k.parent.parent.right;
11230
- if (u && u.color === 1) {
11231
- u.color = 0 /* BLACK */;
11871
+ if (u && u.color === 1 /* RED */) {
11232
11872
  k.parent.color = 0 /* BLACK */;
11873
+ u.color = 0 /* BLACK */;
11233
11874
  k.parent.parent.color = 1 /* RED */;
11234
11875
  k = k.parent.parent;
11235
11876
  } else {
@@ -11237,8 +11878,10 @@ var dataStructureTyped = (() => {
11237
11878
  k = k.parent;
11238
11879
  this._leftRotate(k);
11239
11880
  }
11240
- k.parent.color = 0 /* BLACK */;
11241
- k.parent.parent.color = 1 /* RED */;
11881
+ if (k.parent.color === 1 /* RED */) {
11882
+ k.parent.color = 0 /* BLACK */;
11883
+ k.parent.parent.color = 1 /* RED */;
11884
+ }
11242
11885
  this._rightRotate(k.parent.parent);
11243
11886
  }
11244
11887
  }
@@ -11357,8 +12000,8 @@ var dataStructureTyped = (() => {
11357
12000
  }
11358
12001
  };
11359
12002
 
11360
- // src/data-structures/binary-tree/tree-multimap.ts
11361
- var TreeMultimapNode = class extends AVLTreeNode {
12003
+ // src/data-structures/binary-tree/avl-tree-multi-map.ts
12004
+ var AVLTreeMultiMapNode = class extends AVLTreeNode {
11362
12005
  /**
11363
12006
  * The constructor function initializes a BinaryTreeNode object with a key, value, and count.
11364
12007
  * @param {K} key - The `key` parameter is of type `K` and represents the unique identifier
@@ -11371,11 +12014,26 @@ var dataStructureTyped = (() => {
11371
12014
  */
11372
12015
  constructor(key, value, count = 1) {
11373
12016
  super(key, value);
11374
- __publicField(this, "count");
12017
+ __publicField(this, "_count", 1);
11375
12018
  this.count = count;
11376
12019
  }
12020
+ /**
12021
+ * The function returns the value of the protected variable _count.
12022
+ * @returns The count property of the object, which is of type number.
12023
+ */
12024
+ get count() {
12025
+ return this._count;
12026
+ }
12027
+ /**
12028
+ * The above function sets the value of the count property.
12029
+ * @param {number} value - The value parameter is of type number, which means it can accept any
12030
+ * numeric value.
12031
+ */
12032
+ set count(value) {
12033
+ this._count = value;
12034
+ }
11377
12035
  };
11378
- var TreeMultimap = class _TreeMultimap extends AVLTree {
12036
+ var AVLTreeMultiMap = class _AVLTreeMultiMap extends AVLTree {
11379
12037
  constructor(keysOrNodesOrEntries = [], options) {
11380
12038
  super([], options);
11381
12039
  __publicField(this, "_count", 0);
@@ -11383,6 +12041,11 @@ var dataStructureTyped = (() => {
11383
12041
  this.addMany(keysOrNodesOrEntries);
11384
12042
  }
11385
12043
  // TODO the _count is not accurate after nodes count modified
12044
+ /**
12045
+ * The function calculates the sum of the count property of all nodes in a tree using depth-first
12046
+ * search.
12047
+ * @returns the sum of the count property of all nodes in the tree.
12048
+ */
11386
12049
  get count() {
11387
12050
  let sum = 0;
11388
12051
  this.dfs((node) => sum += node.count);
@@ -11398,10 +12061,19 @@ var dataStructureTyped = (() => {
11398
12061
  * @returns A new instance of the BSTNode class with the specified key, value, and count (if provided).
11399
12062
  */
11400
12063
  createNode(key, value, count) {
11401
- return new TreeMultimapNode(key, value, count);
12064
+ return new AVLTreeMultiMapNode(key, value, count);
11402
12065
  }
12066
+ /**
12067
+ * The function creates a new AVLTreeMultiMap object with the specified options and returns it.
12068
+ * @param [options] - The `options` parameter is an optional object that contains additional
12069
+ * configuration options for creating the `AVLTreeMultiMap` object. It can include properties such as
12070
+ * `iterationType` and `variant`, which are used to specify the type of iteration and the variant of
12071
+ * the tree, respectively. These properties can be
12072
+ * @returns a new instance of the `AVLTreeMultiMap` class, with the provided options merged with the
12073
+ * default options. The returned value is casted as `TREE`.
12074
+ */
11403
12075
  createTree(options) {
11404
- return new _TreeMultimap([], __spreadValues({
12076
+ return new _AVLTreeMultiMap([], __spreadValues({
11405
12077
  iterationType: this.iterationType,
11406
12078
  variant: this.variant
11407
12079
  }, options));
@@ -11438,13 +12110,13 @@ var dataStructureTyped = (() => {
11438
12110
  return node;
11439
12111
  }
11440
12112
  /**
11441
- * The function checks if an keyOrNodeOrEntry is an instance of the TreeMultimapNode class.
12113
+ * The function checks if an keyOrNodeOrEntry is an instance of the AVLTreeMultiMapNode class.
11442
12114
  * @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter is of type `KeyOrNodeOrEntry<K, V, NODE>`.
11443
- * @returns a boolean value indicating whether the keyOrNodeOrEntry is an instance of the TreeMultimapNode
12115
+ * @returns a boolean value indicating whether the keyOrNodeOrEntry is an instance of the AVLTreeMultiMapNode
11444
12116
  * class.
11445
12117
  */
11446
12118
  isNode(keyOrNodeOrEntry) {
11447
- return keyOrNodeOrEntry instanceof TreeMultimapNode;
12119
+ return keyOrNodeOrEntry instanceof AVLTreeMultiMapNode;
11448
12120
  }
11449
12121
  /**
11450
12122
  * Time Complexity: O(log n)
@@ -11662,6 +12334,380 @@ var dataStructureTyped = (() => {
11662
12334
  }
11663
12335
  return void 0;
11664
12336
  }
12337
+ /**
12338
+ * The function replaces an old node with a new node and updates the count property of the new node.
12339
+ * @param {NODE} oldNode - The `oldNode` parameter is of type `NODE` and represents the node that
12340
+ * needs to be replaced in a data structure.
12341
+ * @param {NODE} newNode - The `newNode` parameter is an object of type `NODE`.
12342
+ * @returns The method is returning the result of calling the `_replaceNode` method from the
12343
+ * superclass, after updating the `count` property of the `newNode` object.
12344
+ */
12345
+ _replaceNode(oldNode, newNode) {
12346
+ newNode.count = oldNode.count + newNode.count;
12347
+ return super._replaceNode(oldNode, newNode);
12348
+ }
12349
+ };
12350
+
12351
+ // src/data-structures/binary-tree/tree-multi-map.ts
12352
+ var TreeMultiMapNode = class extends RedBlackTreeNode {
12353
+ /**
12354
+ * The constructor function initializes an instance of a class with a key, value, and count.
12355
+ * @param {K} key - The key parameter is of type K, which represents the type of the key for the
12356
+ * constructor. It is required and must be provided when creating an instance of the class.
12357
+ * @param {V} [value] - The `value` parameter is an optional parameter of type `V`. It represents the
12358
+ * value associated with the key in the constructor. If no value is provided, it will be `undefined`.
12359
+ * @param [count=1] - The "count" parameter is an optional parameter that specifies the number of
12360
+ * times the key-value pair should be repeated. If no value is provided for "count", it defaults to
12361
+ * 1.
12362
+ */
12363
+ constructor(key, value, count = 1) {
12364
+ super(key, value);
12365
+ __publicField(this, "_count", 1);
12366
+ this.count = count;
12367
+ }
12368
+ /**
12369
+ * The function returns the value of the private variable _count.
12370
+ * @returns The count property of the object, which is of type number.
12371
+ */
12372
+ get count() {
12373
+ return this._count;
12374
+ }
12375
+ /**
12376
+ * The above function sets the value of the count property.
12377
+ * @param {number} value - The value parameter is of type number, which means it can accept any
12378
+ * numeric value.
12379
+ */
12380
+ set count(value) {
12381
+ this._count = value;
12382
+ }
12383
+ };
12384
+ var TreeMultiMap = class _TreeMultiMap extends RedBlackTree {
12385
+ /**
12386
+ * The constructor function initializes a new instance of the TreeMultiMap class with optional
12387
+ * initial keys, nodes, or entries.
12388
+ * @param keysOrNodesOrEntries - The `keysOrNodesOrEntries` parameter is an iterable object that can
12389
+ * contain keys, nodes, or entries. It is used to initialize the TreeMultiMap with the provided keys,
12390
+ * nodes, or entries.
12391
+ * @param [options] - The `options` parameter is an optional object that can be passed to the
12392
+ * constructor. It allows you to customize the behavior of the `TreeMultiMap` instance.
12393
+ */
12394
+ constructor(keysOrNodesOrEntries = [], options) {
12395
+ super([], options);
12396
+ __publicField(this, "_count", 0);
12397
+ if (keysOrNodesOrEntries)
12398
+ this.addMany(keysOrNodesOrEntries);
12399
+ }
12400
+ // TODO the _count is not accurate after nodes count modified
12401
+ /**
12402
+ * The function calculates the sum of the count property of all nodes in a tree structure.
12403
+ * @returns the sum of the count property of all nodes in the tree.
12404
+ */
12405
+ get count() {
12406
+ let sum = 0;
12407
+ this.dfs((node) => sum += node.count);
12408
+ return sum;
12409
+ }
12410
+ /**
12411
+ * The function creates a new TreeMultiMapNode object with the specified key, value, and count.
12412
+ * @param {K} key - The key parameter represents the key of the node being created. It is of type K,
12413
+ * which is a generic type that can be replaced with any specific type when using the function.
12414
+ * @param {V} [value] - The `value` parameter is an optional parameter that represents the value
12415
+ * associated with the key in the node. It is of type `V`, which can be any data type.
12416
+ * @param {number} [count] - The `count` parameter represents the number of occurrences of a
12417
+ * key-value pair in the TreeMultiMap. It is an optional parameter, so if it is not provided, it will
12418
+ * default to 1.
12419
+ * @returns a new instance of the TreeMultiMapNode class, casted as NODE.
12420
+ */
12421
+ createNode(key, value, count) {
12422
+ return new TreeMultiMapNode(key, value, count);
12423
+ }
12424
+ /**
12425
+ * The function creates a new instance of a TreeMultiMap with the specified options and returns it.
12426
+ * @param [options] - The `options` parameter is an optional object that contains additional
12427
+ * configuration options for creating the `TreeMultiMap`. It can include properties such as
12428
+ * `keyComparator`, `valueComparator`, `allowDuplicates`, etc.
12429
+ * @returns a new instance of the `TreeMultiMap` class, with the provided options merged with the
12430
+ * existing `iterationType` option. The returned value is casted as `TREE`.
12431
+ */
12432
+ createTree(options) {
12433
+ return new _TreeMultiMap([], __spreadValues({
12434
+ iterationType: this.iterationType
12435
+ }, options));
12436
+ }
12437
+ /**
12438
+ * The function `keyValueOrEntryToNode` takes a key, value, and count and returns a node if the input
12439
+ * is valid.
12440
+ * @param keyOrNodeOrEntry - The parameter `keyOrNodeOrEntry` can be of type `KeyOrNodeOrEntry<K, V,
12441
+ * NODE>`. It can accept three types of values:
12442
+ * @param {V} [value] - The `value` parameter is an optional value of type `V`. It represents the
12443
+ * value associated with a key in a key-value pair.
12444
+ * @param [count=1] - The count parameter is an optional parameter that specifies the number of times
12445
+ * the key-value pair should be added to the node. If not provided, it defaults to 1.
12446
+ * @returns a NODE object or undefined.
12447
+ */
12448
+ keyValueOrEntryToNode(keyOrNodeOrEntry, value, count = 1) {
12449
+ let node;
12450
+ if (keyOrNodeOrEntry === void 0 || keyOrNodeOrEntry === null) {
12451
+ return;
12452
+ } else if (this.isNode(keyOrNodeOrEntry)) {
12453
+ node = keyOrNodeOrEntry;
12454
+ } else if (this.isEntry(keyOrNodeOrEntry)) {
12455
+ const [key, value2] = keyOrNodeOrEntry;
12456
+ if (key === void 0 || key === null) {
12457
+ return;
12458
+ } else {
12459
+ node = this.createNode(key, value2, count);
12460
+ }
12461
+ } else if (!this.isNode(keyOrNodeOrEntry)) {
12462
+ node = this.createNode(keyOrNodeOrEntry, value, count);
12463
+ } else {
12464
+ return;
12465
+ }
12466
+ return node;
12467
+ }
12468
+ /**
12469
+ * The function "isNode" checks if a given key, node, or entry is an instance of the TreeMultiMapNode
12470
+ * class.
12471
+ * @param keyOrNodeOrEntry - The parameter `keyOrNodeOrEntry` can be of type `KeyOrNodeOrEntry<K, V,
12472
+ * NODE>`.
12473
+ * @returns a boolean value indicating whether the input parameter `keyOrNodeOrEntry` is an instance
12474
+ * of the `TreeMultiMapNode` class.
12475
+ */
12476
+ isNode(keyOrNodeOrEntry) {
12477
+ return keyOrNodeOrEntry instanceof TreeMultiMapNode;
12478
+ }
12479
+ /**
12480
+ * Time Complexity: O(log n)
12481
+ * Space Complexity: O(1)
12482
+ */
12483
+ /**
12484
+ * Time Complexity: O(log n)
12485
+ * Space Complexity: O(1)
12486
+ *
12487
+ * The function overrides the add method in TypeScript and adds a new node to the data structure.
12488
+ * @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter can accept three types of values:
12489
+ * @param {V} [value] - The `value` parameter represents the value associated with the key in the
12490
+ * data structure.
12491
+ * @param [count=1] - The `count` parameter represents the number of times the key-value pair should
12492
+ * be added to the data structure. By default, it is set to 1, meaning that the key-value pair will
12493
+ * be added once. However, you can specify a different value for `count` if you want to add
12494
+ * @returns a boolean value.
12495
+ */
12496
+ add(keyOrNodeOrEntry, value, count = 1) {
12497
+ const newNode = this.keyValueOrEntryToNode(keyOrNodeOrEntry, value, count);
12498
+ if (newNode === void 0)
12499
+ return false;
12500
+ const orgNodeCount = (newNode == null ? void 0 : newNode.count) || 0;
12501
+ const inserted = super.add(newNode);
12502
+ if (inserted) {
12503
+ this._count += orgNodeCount;
12504
+ }
12505
+ return true;
12506
+ }
12507
+ /**
12508
+ * Time Complexity: O(log n)
12509
+ * Space Complexity: O(1)
12510
+ */
12511
+ /**
12512
+ * Time Complexity: O(log n)
12513
+ * Space Complexity: O(1)
12514
+ *
12515
+ * The `delete` function in a TypeScript class is used to delete nodes from a binary tree based on a
12516
+ * given identifier, and it returns an array of results containing information about the deleted
12517
+ * nodes.
12518
+ * @param {ReturnType<C> | null | undefined} identifier - The identifier parameter is the value used
12519
+ * to identify the node to be deleted. It can be of any type that is returned by the callback
12520
+ * function. It can also be null or undefined if no node needs to be deleted.
12521
+ * @param {C} callback - The `callback` parameter is a function that takes a node of type `NODE` as
12522
+ * input and returns a value of type `ReturnType<C>`. It is used to determine if a node matches the
12523
+ * identifier for deletion. If no callback is provided, the `_defaultOneParamCallback` function is
12524
+ * used
12525
+ * @param [ignoreCount=false] - A boolean value indicating whether to ignore the count of the target
12526
+ * node when performing deletion. If set to true, the count of the target node will not be considered
12527
+ * and the node will be deleted regardless of its count. If set to false (default), the count of the
12528
+ * target node will be decremented
12529
+ * @returns an array of BinaryTreeDeleteResult<NODE> objects.
12530
+ */
12531
+ delete(identifier, callback = this._defaultOneParamCallback, ignoreCount = false) {
12532
+ const deleteResults = [];
12533
+ if (identifier === null)
12534
+ return deleteResults;
12535
+ const deleteHelper = (node) => {
12536
+ let targetNode = this._Sentinel;
12537
+ let currentNode;
12538
+ while (node !== this._Sentinel) {
12539
+ if (node && callback(node) === identifier) {
12540
+ targetNode = node;
12541
+ }
12542
+ if (node && identifier && callback(node) <= identifier) {
12543
+ node = node.right;
12544
+ } else {
12545
+ node = node == null ? void 0 : node.left;
12546
+ }
12547
+ }
12548
+ if (targetNode === this._Sentinel) {
12549
+ return;
12550
+ }
12551
+ if (ignoreCount || targetNode.count <= 1) {
12552
+ let parentNode = targetNode;
12553
+ let parentNodeOriginalColor = parentNode.color;
12554
+ if (targetNode.left === this._Sentinel) {
12555
+ currentNode = targetNode.right;
12556
+ this._rbTransplant(targetNode, targetNode.right);
12557
+ } else if (targetNode.right === this._Sentinel) {
12558
+ currentNode = targetNode.left;
12559
+ this._rbTransplant(targetNode, targetNode.left);
12560
+ } else {
12561
+ parentNode = this.getLeftMost(targetNode.right);
12562
+ parentNodeOriginalColor = parentNode.color;
12563
+ currentNode = parentNode.right;
12564
+ if (parentNode.parent === targetNode) {
12565
+ currentNode.parent = parentNode;
12566
+ } else {
12567
+ this._rbTransplant(parentNode, parentNode.right);
12568
+ parentNode.right = targetNode.right;
12569
+ parentNode.right.parent = parentNode;
12570
+ }
12571
+ this._rbTransplant(targetNode, parentNode);
12572
+ parentNode.left = targetNode.left;
12573
+ parentNode.left.parent = parentNode;
12574
+ parentNode.color = targetNode.color;
12575
+ }
12576
+ if (parentNodeOriginalColor === 0 /* BLACK */) {
12577
+ this._fixDelete(currentNode);
12578
+ }
12579
+ this._size--;
12580
+ this._count -= targetNode.count;
12581
+ deleteResults.push({ deleted: targetNode, needBalanced: void 0 });
12582
+ } else {
12583
+ targetNode.count--;
12584
+ this._count--;
12585
+ }
12586
+ };
12587
+ deleteHelper(this.root);
12588
+ return deleteResults;
12589
+ }
12590
+ /**
12591
+ * Time Complexity: O(1)
12592
+ * Space Complexity: O(1)
12593
+ */
12594
+ /**
12595
+ * Time Complexity: O(1)
12596
+ * Space Complexity: O(1)
12597
+ *
12598
+ * The "clear" function overrides the parent class's "clear" function and also resets the count to
12599
+ * zero.
12600
+ */
12601
+ clear() {
12602
+ super.clear();
12603
+ this._count = 0;
12604
+ }
12605
+ /**
12606
+ * Time Complexity: O(n log n)
12607
+ * Space Complexity: O(log n)
12608
+ */
12609
+ /**
12610
+ * Time Complexity: O(n log n)
12611
+ * Space Complexity: O(log n)
12612
+ *
12613
+ * The `perfectlyBalance` function takes a sorted array of nodes and builds a balanced binary search
12614
+ * tree using either a recursive or iterative approach.
12615
+ * @param iterationType - The `iterationType` parameter is an optional parameter that specifies the
12616
+ * type of iteration to use when building the balanced binary search tree. It can have two possible
12617
+ * values:
12618
+ * @returns a boolean value.
12619
+ */
12620
+ perfectlyBalance(iterationType = this.iterationType) {
12621
+ const sorted = this.dfs((node) => node, "in"), n = sorted.length;
12622
+ if (sorted.length < 1)
12623
+ return false;
12624
+ this.clear();
12625
+ if (iterationType === "RECURSIVE" /* RECURSIVE */) {
12626
+ const buildBalanceBST = (l, r) => {
12627
+ if (l > r)
12628
+ return;
12629
+ const m = l + Math.floor((r - l) / 2);
12630
+ const midNode = sorted[m];
12631
+ this.add(midNode.key, midNode.value, midNode.count);
12632
+ buildBalanceBST(l, m - 1);
12633
+ buildBalanceBST(m + 1, r);
12634
+ };
12635
+ buildBalanceBST(0, n - 1);
12636
+ return true;
12637
+ } else {
12638
+ const stack = [[0, n - 1]];
12639
+ while (stack.length > 0) {
12640
+ const popped = stack.pop();
12641
+ if (popped) {
12642
+ const [l, r] = popped;
12643
+ if (l <= r) {
12644
+ const m = l + Math.floor((r - l) / 2);
12645
+ const midNode = sorted[m];
12646
+ this.add(midNode.key, midNode.value, midNode.count);
12647
+ stack.push([m + 1, r]);
12648
+ stack.push([l, m - 1]);
12649
+ }
12650
+ }
12651
+ }
12652
+ return true;
12653
+ }
12654
+ }
12655
+ /**
12656
+ * Time complexity: O(n)
12657
+ * Space complexity: O(n)
12658
+ */
12659
+ /**
12660
+ * Time complexity: O(n)
12661
+ * Space complexity: O(n)
12662
+ *
12663
+ * The function overrides the clone method to create a deep copy of a tree object.
12664
+ * @returns The `clone()` method is returning a cloned instance of the `TREE` object.
12665
+ */
12666
+ clone() {
12667
+ const cloned = this.createTree();
12668
+ this.bfs((node) => cloned.add(node.key, node.value, node.count));
12669
+ return cloned;
12670
+ }
12671
+ /**
12672
+ * The function swaps the properties of two nodes in a binary search tree.
12673
+ * @param srcNode - The source node that needs to be swapped with the destination node. It can be
12674
+ * either a key or a node object.
12675
+ * @param destNode - The `destNode` parameter is the node in the binary search tree where the
12676
+ * properties will be swapped with the `srcNode`.
12677
+ * @returns The method is returning the `destNode` after swapping its properties with the `srcNode`.
12678
+ * If both `srcNode` and `destNode` are valid nodes, the method swaps their `key`, `value`, `count`,
12679
+ * and `color` properties. If the swapping is successful, the method returns the modified `destNode`.
12680
+ * If either `srcNode` or `destNode` is
12681
+ */
12682
+ _swapProperties(srcNode, destNode) {
12683
+ srcNode = this.ensureNode(srcNode);
12684
+ destNode = this.ensureNode(destNode);
12685
+ if (srcNode && destNode) {
12686
+ const { key, value, count, color } = destNode;
12687
+ const tempNode = this.createNode(key, value, count);
12688
+ if (tempNode) {
12689
+ tempNode.color = color;
12690
+ destNode.key = srcNode.key;
12691
+ destNode.value = srcNode.value;
12692
+ destNode.count = srcNode.count;
12693
+ destNode.color = srcNode.color;
12694
+ srcNode.key = tempNode.key;
12695
+ srcNode.value = tempNode.value;
12696
+ srcNode.count = tempNode.count;
12697
+ srcNode.color = tempNode.color;
12698
+ }
12699
+ return destNode;
12700
+ }
12701
+ return void 0;
12702
+ }
12703
+ /**
12704
+ * The function replaces an old node with a new node and updates the count property of the new node.
12705
+ * @param {NODE} oldNode - The `oldNode` parameter is of type `NODE` and represents the node that
12706
+ * needs to be replaced in the data structure.
12707
+ * @param {NODE} newNode - The `newNode` parameter is an object of type `NODE`.
12708
+ * @returns The method is returning the result of calling the `_replaceNode` method from the
12709
+ * superclass, after updating the `count` property of the `newNode` object.
12710
+ */
11665
12711
  _replaceNode(oldNode, newNode) {
11666
12712
  newNode.count = oldNode.count + newNode.count;
11667
12713
  return super._replaceNode(oldNode, newNode);
@@ -11670,24 +12716,90 @@ var dataStructureTyped = (() => {
11670
12716
 
11671
12717
  // src/data-structures/tree/tree.ts
11672
12718
  var TreeNode = class _TreeNode {
12719
+ /**
12720
+ * The constructor function initializes a TreeNode object with a key, optional value, and optional
12721
+ * children.
12722
+ * @param {string} key - A string representing the key of the tree node.
12723
+ * @param {V} [value] - The `value` parameter is an optional parameter of type `V`. It represents the
12724
+ * value associated with the node. If no value is provided, it defaults to `undefined`.
12725
+ * @param {TreeNode<V>[]} [children] - The `children` parameter is an optional array of `TreeNode<V>`
12726
+ * objects. It represents the child nodes of the current node. If no children are provided, the
12727
+ * default value is an empty array.
12728
+ */
11673
12729
  constructor(key, value, children) {
11674
- __publicField(this, "key");
11675
- __publicField(this, "value");
11676
- __publicField(this, "children");
11677
- this.key = key;
11678
- this.value = value || void 0;
11679
- this.children = children || [];
12730
+ __publicField(this, "_key");
12731
+ __publicField(this, "_value");
12732
+ __publicField(this, "_children");
12733
+ this._key = key;
12734
+ this._value = value || void 0;
12735
+ this._children = children || [];
12736
+ }
12737
+ /**
12738
+ * The function returns the value of the protected variable _key.
12739
+ * @returns The value of the `_key` property, which is a string.
12740
+ */
12741
+ get key() {
12742
+ return this._key;
11680
12743
  }
12744
+ /**
12745
+ * The above function sets the value of a protected variable called "key".
12746
+ * @param {string} value - The value parameter is a string that represents the value to be assigned
12747
+ * to the key.
12748
+ */
12749
+ set key(value) {
12750
+ this._key = value;
12751
+ }
12752
+ /**
12753
+ * The function returns the value stored in a variable, or undefined if the variable is empty.
12754
+ * @returns The value of the variable `_value` is being returned.
12755
+ */
12756
+ get value() {
12757
+ return this._value;
12758
+ }
12759
+ /**
12760
+ * The function sets the value of a variable.
12761
+ * @param {V | undefined} value - The parameter "value" is of type "V | undefined", which means it
12762
+ * can accept a value of type "V" or it can be undefined.
12763
+ */
12764
+ set value(value) {
12765
+ this._value = value;
12766
+ }
12767
+ /**
12768
+ * The function returns an array of TreeNode objects or undefined.
12769
+ * @returns The `children` property is being returned. It is of type `TreeNode<V>[] | undefined`,
12770
+ * which means it can either be an array of `TreeNode<V>` objects or `undefined`.
12771
+ */
12772
+ get children() {
12773
+ return this._children;
12774
+ }
12775
+ /**
12776
+ * The function sets the value of the children property of a TreeNode object.
12777
+ * @param {TreeNode<V>[] | undefined} value - The value parameter is of type TreeNode<V>[] |
12778
+ * undefined. This means that it can accept an array of TreeNode objects or undefined.
12779
+ */
12780
+ set children(value) {
12781
+ this._children = value;
12782
+ }
12783
+ /**
12784
+ * The function `addChildren` adds one or more child nodes to the current node.
12785
+ * @param {TreeNode<V> | TreeNode<V>[]} children - The `children` parameter can be either a single
12786
+ * `TreeNode<V>` object or an array of `TreeNode<V>` objects.
12787
+ */
11681
12788
  addChildren(children) {
11682
- if (!this.children) {
11683
- this.children = [];
12789
+ if (!this._children) {
12790
+ this._children = [];
11684
12791
  }
11685
12792
  if (children instanceof _TreeNode) {
11686
- this.children.push(children);
12793
+ this._children.push(children);
11687
12794
  } else {
11688
- this.children = this.children.concat(children);
12795
+ this._children = this._children.concat(children);
11689
12796
  }
11690
12797
  }
12798
+ /**
12799
+ * The function `getHeight()` calculates the maximum depth of a tree structure by performing a
12800
+ * breadth-first search.
12801
+ * @returns the maximum depth or height of the tree.
12802
+ */
11691
12803
  getHeight() {
11692
12804
  let maxDepth = 0;
11693
12805
  if (this) {
@@ -11695,10 +12807,10 @@ var dataStructureTyped = (() => {
11695
12807
  if (level > maxDepth) {
11696
12808
  maxDepth = level;
11697
12809
  }
11698
- const { children } = node;
11699
- if (children) {
11700
- for (let i = 0, len = children.length; i < len; i++) {
11701
- bfs(children[i], level + 1);
12810
+ const { _children } = node;
12811
+ if (_children) {
12812
+ for (let i = 0, len = _children.length; i < len; i++) {
12813
+ bfs(_children[i], level + 1);
11702
12814
  }
11703
12815
  }
11704
12816
  };
@@ -11710,6 +12822,14 @@ var dataStructureTyped = (() => {
11710
12822
 
11711
12823
  // src/data-structures/priority-queue/priority-queue.ts
11712
12824
  var PriorityQueue = class extends Heap {
12825
+ /**
12826
+ * The constructor initializes a priority queue with optional elements and options.
12827
+ * @param elements - The `elements` parameter is an iterable object that contains the initial
12828
+ * elements to be added to the priority queue. It is an optional parameter and if not provided, the
12829
+ * priority queue will be initialized as empty.
12830
+ * @param [options] - The `options` parameter is an optional object that can be used to customize the
12831
+ * behavior of the priority queue. It can contain the following properties:
12832
+ */
11713
12833
  constructor(elements = [], options) {
11714
12834
  super(elements, options);
11715
12835
  }
@@ -11717,6 +12837,17 @@ var dataStructureTyped = (() => {
11717
12837
 
11718
12838
  // src/data-structures/priority-queue/min-priority-queue.ts
11719
12839
  var MinPriorityQueue = class extends PriorityQueue {
12840
+ /**
12841
+ * The constructor initializes a PriorityQueue with optional elements and options, including a
12842
+ * comparator function.
12843
+ * @param elements - The `elements` parameter is an iterable object that contains the initial
12844
+ * elements to be added to the priority queue. It is optional and defaults to an empty array if not
12845
+ * provided.
12846
+ * @param options - The `options` parameter is an object that contains additional configuration
12847
+ * options for the priority queue. In this case, it has a property called `comparator` which is a
12848
+ * function used to compare elements in the priority queue. The `comparator` function takes two
12849
+ * parameters `a` and `b`,
12850
+ */
11720
12851
  constructor(elements = [], options = {
11721
12852
  comparator: (a, b) => {
11722
12853
  if (!(typeof a === "number" && typeof b === "number")) {
@@ -11732,6 +12863,16 @@ var dataStructureTyped = (() => {
11732
12863
 
11733
12864
  // src/data-structures/priority-queue/max-priority-queue.ts
11734
12865
  var MaxPriorityQueue = class extends PriorityQueue {
12866
+ /**
12867
+ * The constructor initializes a PriorityQueue with optional elements and options, including a
12868
+ * comparator function.
12869
+ * @param elements - The `elements` parameter is an iterable object that contains the initial
12870
+ * elements to be added to the priority queue. It is optional and defaults to an empty array if not
12871
+ * provided.
12872
+ * @param options - The `options` parameter is an object that contains additional configuration
12873
+ * options for the priority queue. In this case, it has a property called `comparator` which is a
12874
+ * function used to compare elements in the priority queue.
12875
+ */
11735
12876
  constructor(elements = [], options = {
11736
12877
  comparator: (a, b) => {
11737
12878
  if (!(typeof a === "number" && typeof b === "number")) {
@@ -11796,7 +12937,7 @@ var dataStructureTyped = (() => {
11796
12937
  return this._rows;
11797
12938
  }
11798
12939
  /**
11799
- * The function returns the value of the private variable _cols.
12940
+ * The function returns the value of the protected variable _cols.
11800
12941
  * @returns The number of columns.
11801
12942
  */
11802
12943
  get cols() {
@@ -12291,12 +13432,60 @@ var dataStructureTyped = (() => {
12291
13432
  // src/data-structures/trie/trie.ts
12292
13433
  var TrieNode = class {
12293
13434
  constructor(key) {
12294
- __publicField(this, "key");
12295
- __publicField(this, "children");
12296
- __publicField(this, "isEnd");
12297
- this.key = key;
12298
- this.isEnd = false;
12299
- this.children = /* @__PURE__ */ new Map();
13435
+ __publicField(this, "_key");
13436
+ __publicField(this, "_children");
13437
+ __publicField(this, "_isEnd");
13438
+ this._key = key;
13439
+ this._isEnd = false;
13440
+ this._children = /* @__PURE__ */ new Map();
13441
+ }
13442
+ /**
13443
+ * The function returns the value of the protected variable _key.
13444
+ * @returns The value of the `_key` property, which is a string.
13445
+ */
13446
+ get key() {
13447
+ return this._key;
13448
+ }
13449
+ /**
13450
+ * The above function sets the value of a protected variable called "key".
13451
+ * @param {string} value - The value parameter is a string that represents the value to be assigned
13452
+ * to the key.
13453
+ */
13454
+ set key(value) {
13455
+ this._key = value;
13456
+ }
13457
+ /**
13458
+ * The function returns the children of a TrieNode as a Map.
13459
+ * @returns The `children` property of the TrieNode object, which is a Map containing string keys and
13460
+ * TrieNode values.
13461
+ */
13462
+ get children() {
13463
+ return this._children;
13464
+ }
13465
+ /**
13466
+ * The function sets the value of the `_children` property of a TrieNode object.
13467
+ * @param value - The value parameter is a Map object that represents the children of a TrieNode. The
13468
+ * keys of the map are strings, which represent the characters that are associated with each child
13469
+ * TrieNode. The values of the map are TrieNode objects, which represent the child nodes of the
13470
+ * current TrieNode.
13471
+ */
13472
+ set children(value) {
13473
+ this._children = value;
13474
+ }
13475
+ /**
13476
+ * The function returns a boolean value indicating whether a certain condition is met.
13477
+ * @returns The method is returning a boolean value, specifically the value of the variable `_isEnd`.
13478
+ */
13479
+ get isEnd() {
13480
+ return this._isEnd;
13481
+ }
13482
+ /**
13483
+ * The function sets the value of the "_isEnd" property.
13484
+ * @param {boolean} value - The value parameter is a boolean value that indicates whether the current
13485
+ * state is the end state or not.
13486
+ */
13487
+ set isEnd(value) {
13488
+ this._isEnd = value;
12300
13489
  }
12301
13490
  };
12302
13491
  var Trie = class _Trie extends IterableElementBase {
@@ -12329,9 +13518,8 @@ var dataStructureTyped = (() => {
12329
13518
  return this._size;
12330
13519
  }
12331
13520
  /**
12332
- * The caseSensitive function is a getter that returns the value of the private _caseSensitive property.
12333
- *
12334
- * @return The value of the _casesensitive private variable
13521
+ * The caseSensitive function is a getter that returns the value of the protected _caseSensitive property.
13522
+ * @return The value of the _caseSensitive protected variable
12335
13523
  */
12336
13524
  get caseSensitive() {
12337
13525
  return this._caseSensitive;
@@ -12344,12 +13532,12 @@ var dataStructureTyped = (() => {
12344
13532
  return this._root;
12345
13533
  }
12346
13534
  /**
12347
- * Time Complexity: O(M), where M is the length of the word being added.
12348
- * Space Complexity: O(M) - Each character in the word adds a TrieNode.
13535
+ * Time Complexity: O(l), where l is the length of the word being added.
13536
+ * Space Complexity: O(l) - Each character in the word adds a TrieNode.
12349
13537
  */
12350
13538
  /**
12351
- * Time Complexity: O(M), where M is the length of the word being added.
12352
- * Space Complexity: O(M) - Each character in the word adds a TrieNode.
13539
+ * Time Complexity: O(l), where l is the length of the word being added.
13540
+ * Space Complexity: O(l) - Each character in the word adds a TrieNode.
12353
13541
  *
12354
13542
  * Add a word to the Trie structure.
12355
13543
  * @param {string} word - The word to add.
@@ -12375,11 +13563,11 @@ var dataStructureTyped = (() => {
12375
13563
  return isNewWord;
12376
13564
  }
12377
13565
  /**
12378
- * Time Complexity: O(M), where M is the length of the input word.
13566
+ * Time Complexity: O(l), where l is the length of the input word.
12379
13567
  * Space Complexity: O(1) - Constant space.
12380
13568
  */
12381
13569
  /**
12382
- * Time Complexity: O(M), where M is the length of the input word.
13570
+ * Time Complexity: O(l), where l is the length of the input word.
12383
13571
  * Space Complexity: O(1) - Constant space.
12384
13572
  *
12385
13573
  * Check if the Trie contains a given word.
@@ -12398,6 +13586,13 @@ var dataStructureTyped = (() => {
12398
13586
  return cur.isEnd;
12399
13587
  }
12400
13588
  /**
13589
+ * Time Complexity: O(1)
13590
+ * Space Complexity: O(1)
13591
+ */
13592
+ /**
13593
+ * Time Complexity: O(1)
13594
+ * Space Complexity: O(1)
13595
+ *
12401
13596
  * The isEmpty function checks if the size of the queue is 0.
12402
13597
  * @return True if the size of the queue is 0
12403
13598
  */
@@ -12405,12 +13600,26 @@ var dataStructureTyped = (() => {
12405
13600
  return this.size === 0;
12406
13601
  }
12407
13602
  /**
12408
- * Time Complexity: O(M), where M is the length of the word being deleted.
12409
- * Space Complexity: O(M) - Due to the recursive DFS approach.
13603
+ * Time Complexity: O(1)
13604
+ * Space Complexity: O(1)
12410
13605
  */
12411
13606
  /**
12412
- * Time Complexity: O(M), where M is the length of the word being deleted.
12413
- * Space Complexity: O(M) - Due to the recursive DFS approach.
13607
+ * Time Complexity: O(1)
13608
+ * Space Complexity: O(1)
13609
+ *
13610
+ * The clear function resets the size of the Trie to 0 and creates a new root TrieNode.
13611
+ */
13612
+ clear() {
13613
+ this._size = 0;
13614
+ this._root = new TrieNode("");
13615
+ }
13616
+ /**
13617
+ * Time Complexity: O(l), where l is the length of the word being deleted.
13618
+ * Space Complexity: O(n) - Due to the recursive DFS approach.
13619
+ */
13620
+ /**
13621
+ * Time Complexity: O(l), where l is the length of the word being deleted.
13622
+ * Space Complexity: O(n) - Due to the recursive DFS approach.
12414
13623
  *
12415
13624
  * Remove a word from the Trie structure.
12416
13625
  * @param{string} word - The word to delete.
@@ -12451,11 +13660,11 @@ var dataStructureTyped = (() => {
12451
13660
  return isDeleted;
12452
13661
  }
12453
13662
  /**
12454
- * Time Complexity: O(N), where N is the total number of nodes in the trie.
13663
+ * Time Complexity: O(n), where n is the total number of nodes in the trie.
12455
13664
  * Space Complexity: O(1) - Constant space.
12456
13665
  */
12457
13666
  /**
12458
- * Time Complexity: O(N), where N is the total number of nodes in the trie.
13667
+ * Time Complexity: O(n), where n is the total number of nodes in the trie.
12459
13668
  * Space Complexity: O(1) - Constant space.
12460
13669
  *
12461
13670
  */
@@ -12479,11 +13688,11 @@ var dataStructureTyped = (() => {
12479
13688
  return maxDepth;
12480
13689
  }
12481
13690
  /**
12482
- * Time Complexity: O(M), where M is the length of the input prefix.
13691
+ * Time Complexity: O(l), where l is the length of the input prefix.
12483
13692
  * Space Complexity: O(1) - Constant space.
12484
13693
  */
12485
13694
  /**
12486
- * Time Complexity: O(M), where M is the length of the input prefix.
13695
+ * Time Complexity: O(l), where l is the length of the input prefix.
12487
13696
  * Space Complexity: O(1) - Constant space.
12488
13697
  *
12489
13698
  * Check if a given input string has an absolute prefix in the Trie, meaning it's not a complete word.
@@ -12502,11 +13711,11 @@ var dataStructureTyped = (() => {
12502
13711
  return !cur.isEnd;
12503
13712
  }
12504
13713
  /**
12505
- * Time Complexity: O(M), where M is the length of the input prefix.
13714
+ * Time Complexity: O(l), where l is the length of the input prefix.
12506
13715
  * Space Complexity: O(1) - Constant space.
12507
13716
  */
12508
13717
  /**
12509
- * Time Complexity: O(M), where M is the length of the input prefix.
13718
+ * Time Complexity: O(l), where l is the length of the input prefix.
12510
13719
  * Space Complexity: O(1) - Constant space.
12511
13720
  *
12512
13721
  * Check if a given input string is a prefix of any existing word in the Trie, whether as an absolute prefix or a complete word.
@@ -12525,12 +13734,12 @@ var dataStructureTyped = (() => {
12525
13734
  return true;
12526
13735
  }
12527
13736
  /**
12528
- * Time Complexity: O(N), where N is the total number of nodes in the trie.
12529
- * Space Complexity: O(M), where M is the length of the input prefix.
13737
+ * Time Complexity: O(n), where n is the total number of nodes in the trie.
13738
+ * Space Complexity: O(l), where l is the length of the input prefix.
12530
13739
  */
12531
13740
  /**
12532
- * Time Complexity: O(N), where N is the total number of nodes in the trie.
12533
- * Space Complexity: O(M), where M is the length of the input prefix.
13741
+ * Time Complexity: O(n), where n is the total number of nodes in the trie.
13742
+ * Space Complexity: O(l), where l is the length of the input prefix.
12534
13743
  *
12535
13744
  * Check if the input string is a common prefix in the Trie, meaning it's a prefix shared by all words in the Trie.
12536
13745
  * @param {string} input - The input string representing the common prefix to check for.
@@ -12554,12 +13763,12 @@ var dataStructureTyped = (() => {
12554
13763
  return commonPre === input;
12555
13764
  }
12556
13765
  /**
12557
- * Time Complexity: O(N), where N is the total number of nodes in the trie.
12558
- * Space Complexity: O(M), where M is the length of the longest common prefix.
13766
+ * Time Complexity: O(n), where n is the total number of nodes in the trie.
13767
+ * Space Complexity: O(l), where l is the length of the longest common prefix.
12559
13768
  */
12560
13769
  /**
12561
- * Time Complexity: O(N), where N is the total number of nodes in the trie.
12562
- * Space Complexity: O(M), where M is the length of the longest common prefix.
13770
+ * Time Complexity: O(n), where n is the total number of nodes in the trie.
13771
+ * Space Complexity: O(l), where l is the length of the longest common prefix.
12563
13772
  *
12564
13773
  * Get the longest common prefix among all the words stored in the Trie.
12565
13774
  * @returns {string} The longest common prefix found in the Trie.
@@ -12579,12 +13788,12 @@ var dataStructureTyped = (() => {
12579
13788
  return commonPre;
12580
13789
  }
12581
13790
  /**
12582
- * Time Complexity: O(K * L), where K is the number of words retrieved, and L is the average length of the words.
12583
- * Space Complexity: O(K * L) - The space required for the output array.
13791
+ * Time Complexity: O(w * l), where w is the number of words retrieved, and l is the average length of the words.
13792
+ * Space Complexity: O(w * l) - The space required for the output array.
12584
13793
  */
12585
13794
  /**
12586
- * Time Complexity: O(K * L), where K is the number of words retrieved, and L is the average length of the words.
12587
- * Space Complexity: O(K * L) - The space required for the output array.
13795
+ * Time Complexity: O(w * l), where w is the number of words retrieved, and l is the average length of the words.
13796
+ * Space Complexity: O(w * l) - The space required for the output array.
12588
13797
  *
12589
13798
  * The `getAll` function returns an array of all words in a Trie data structure that start with a given prefix.
12590
13799
  * @param {string} prefix - The `prefix` parameter is a string that represents the prefix that we want to search for in the
@@ -12693,6 +13902,17 @@ var dataStructureTyped = (() => {
12693
13902
  }
12694
13903
  return newTrie;
12695
13904
  }
13905
+ /**
13906
+ * Time Complexity: O(n)
13907
+ * Space Complexity: O(n)
13908
+ */
13909
+ /**
13910
+ * Time Complexity: O(n)
13911
+ * Space Complexity: O(n)
13912
+ *
13913
+ * The function `_getIterator` returns an iterable iterator that performs a depth-first search on a
13914
+ * trie data structure and yields all the paths to the end nodes.
13915
+ */
12696
13916
  *_getIterator() {
12697
13917
  function* _dfs(node, path) {
12698
13918
  if (node.isEnd) {
@@ -12705,11 +13925,11 @@ var dataStructureTyped = (() => {
12705
13925
  yield* __yieldStar(_dfs(this.root, ""));
12706
13926
  }
12707
13927
  /**
12708
- * Time Complexity: O(M), where M is the length of the input string.
13928
+ * Time Complexity: O(l), where l is the length of the input string.
12709
13929
  * Space Complexity: O(1) - Constant space.
12710
13930
  */
12711
13931
  /**
12712
- * Time Complexity: O(M), where M is the length of the input string.
13932
+ * Time Complexity: O(l), where l is the length of the input string.
12713
13933
  * Space Complexity: O(1) - Constant space.
12714
13934
  *
12715
13935
  * @param str