data-structure-typed 1.50.2 → 1.50.3

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 (162) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/README.md +17 -15
  3. package/README_zh-CN.md +1 -1
  4. package/SPECIFICATION.md +56 -0
  5. package/SPONSOR-zh-CN.md +90 -0
  6. package/SPONSOR.md +54 -0
  7. package/benchmark/report.html +13 -13
  8. package/benchmark/report.json +149 -155
  9. package/dist/cjs/data-structures/base/iterable-base.d.ts +6 -0
  10. package/dist/cjs/data-structures/base/iterable-base.js.map +1 -1
  11. package/dist/cjs/data-structures/binary-tree/avl-tree.d.ts +29 -1
  12. package/dist/cjs/data-structures/binary-tree/avl-tree.js +33 -1
  13. package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +1 -1
  14. package/dist/cjs/data-structures/binary-tree/binary-indexed-tree.d.ts +22 -0
  15. package/dist/cjs/data-structures/binary-tree/binary-indexed-tree.js +22 -0
  16. package/dist/cjs/data-structures/binary-tree/binary-indexed-tree.js.map +1 -1
  17. package/dist/cjs/data-structures/binary-tree/binary-tree.d.ts +1 -1
  18. package/dist/cjs/data-structures/binary-tree/binary-tree.js +1 -1
  19. package/dist/cjs/data-structures/binary-tree/bst.d.ts +46 -13
  20. package/dist/cjs/data-structures/binary-tree/bst.js +46 -13
  21. package/dist/cjs/data-structures/binary-tree/bst.js.map +1 -1
  22. package/dist/cjs/data-structures/binary-tree/rb-tree.d.ts +54 -2
  23. package/dist/cjs/data-structures/binary-tree/rb-tree.js +73 -15
  24. package/dist/cjs/data-structures/binary-tree/rb-tree.js.map +1 -1
  25. package/dist/cjs/data-structures/binary-tree/segment-tree.d.ts +99 -6
  26. package/dist/cjs/data-structures/binary-tree/segment-tree.js +127 -10
  27. package/dist/cjs/data-structures/binary-tree/segment-tree.js.map +1 -1
  28. package/dist/cjs/data-structures/binary-tree/tree-multimap.d.ts +35 -2
  29. package/dist/cjs/data-structures/binary-tree/tree-multimap.js +38 -0
  30. package/dist/cjs/data-structures/binary-tree/tree-multimap.js.map +1 -1
  31. package/dist/cjs/data-structures/graph/abstract-graph.d.ts +0 -78
  32. package/dist/cjs/data-structures/graph/abstract-graph.js +0 -189
  33. package/dist/cjs/data-structures/graph/abstract-graph.js.map +1 -1
  34. package/dist/cjs/data-structures/graph/directed-graph.d.ts +59 -0
  35. package/dist/cjs/data-structures/graph/directed-graph.js +105 -0
  36. package/dist/cjs/data-structures/graph/directed-graph.js.map +1 -1
  37. package/dist/cjs/data-structures/graph/undirected-graph.d.ts +60 -7
  38. package/dist/cjs/data-structures/graph/undirected-graph.js +126 -18
  39. package/dist/cjs/data-structures/graph/undirected-graph.js.map +1 -1
  40. package/dist/cjs/data-structures/hash/hash-map.d.ts +143 -23
  41. package/dist/cjs/data-structures/hash/hash-map.js +196 -62
  42. package/dist/cjs/data-structures/hash/hash-map.js.map +1 -1
  43. package/dist/cjs/data-structures/heap/heap.d.ts +29 -19
  44. package/dist/cjs/data-structures/heap/heap.js +29 -20
  45. package/dist/cjs/data-structures/heap/heap.js.map +1 -1
  46. package/dist/cjs/data-structures/linked-list/doubly-linked-list.d.ts +71 -25
  47. package/dist/cjs/data-structures/linked-list/doubly-linked-list.js +83 -25
  48. package/dist/cjs/data-structures/linked-list/doubly-linked-list.js.map +1 -1
  49. package/dist/cjs/data-structures/linked-list/singly-linked-list.d.ts +26 -3
  50. package/dist/cjs/data-structures/linked-list/singly-linked-list.js +34 -3
  51. package/dist/cjs/data-structures/linked-list/singly-linked-list.js.map +1 -1
  52. package/dist/cjs/data-structures/linked-list/skip-linked-list.d.ts +2 -2
  53. package/dist/cjs/data-structures/linked-list/skip-linked-list.js +2 -2
  54. package/dist/cjs/data-structures/matrix/matrix.d.ts +1 -1
  55. package/dist/cjs/data-structures/matrix/matrix.js +1 -1
  56. package/dist/cjs/data-structures/priority-queue/max-priority-queue.d.ts +10 -0
  57. package/dist/cjs/data-structures/priority-queue/max-priority-queue.js +10 -0
  58. package/dist/cjs/data-structures/priority-queue/max-priority-queue.js.map +1 -1
  59. package/dist/cjs/data-structures/priority-queue/min-priority-queue.d.ts +11 -0
  60. package/dist/cjs/data-structures/priority-queue/min-priority-queue.js +11 -0
  61. package/dist/cjs/data-structures/priority-queue/min-priority-queue.js.map +1 -1
  62. package/dist/cjs/data-structures/priority-queue/priority-queue.d.ts +8 -0
  63. package/dist/cjs/data-structures/priority-queue/priority-queue.js +8 -0
  64. package/dist/cjs/data-structures/priority-queue/priority-queue.js.map +1 -1
  65. package/dist/cjs/data-structures/queue/deque.d.ts +95 -21
  66. package/dist/cjs/data-structures/queue/deque.js +100 -16
  67. package/dist/cjs/data-structures/queue/deque.js.map +1 -1
  68. package/dist/cjs/data-structures/queue/queue.d.ts +65 -45
  69. package/dist/cjs/data-structures/queue/queue.js +65 -45
  70. package/dist/cjs/data-structures/queue/queue.js.map +1 -1
  71. package/dist/cjs/data-structures/stack/stack.d.ts +36 -22
  72. package/dist/cjs/data-structures/stack/stack.js +36 -22
  73. package/dist/cjs/data-structures/stack/stack.js.map +1 -1
  74. package/dist/cjs/data-structures/tree/tree.d.ts +57 -3
  75. package/dist/cjs/data-structures/tree/tree.js +77 -11
  76. package/dist/cjs/data-structures/tree/tree.js.map +1 -1
  77. package/dist/cjs/data-structures/trie/trie.d.ts +100 -36
  78. package/dist/cjs/data-structures/trie/trie.js +115 -36
  79. package/dist/cjs/data-structures/trie/trie.js.map +1 -1
  80. package/dist/mjs/data-structures/base/iterable-base.d.ts +6 -0
  81. package/dist/mjs/data-structures/binary-tree/avl-tree.d.ts +29 -1
  82. package/dist/mjs/data-structures/binary-tree/avl-tree.js +34 -2
  83. package/dist/mjs/data-structures/binary-tree/binary-indexed-tree.d.ts +22 -0
  84. package/dist/mjs/data-structures/binary-tree/binary-indexed-tree.js +22 -0
  85. package/dist/mjs/data-structures/binary-tree/binary-tree.d.ts +1 -1
  86. package/dist/mjs/data-structures/binary-tree/binary-tree.js +1 -1
  87. package/dist/mjs/data-structures/binary-tree/bst.d.ts +46 -13
  88. package/dist/mjs/data-structures/binary-tree/bst.js +46 -13
  89. package/dist/mjs/data-structures/binary-tree/rb-tree.d.ts +54 -2
  90. package/dist/mjs/data-structures/binary-tree/rb-tree.js +74 -16
  91. package/dist/mjs/data-structures/binary-tree/segment-tree.d.ts +99 -6
  92. package/dist/mjs/data-structures/binary-tree/segment-tree.js +127 -10
  93. package/dist/mjs/data-structures/binary-tree/tree-multimap.d.ts +35 -2
  94. package/dist/mjs/data-structures/binary-tree/tree-multimap.js +38 -1
  95. package/dist/mjs/data-structures/graph/abstract-graph.d.ts +0 -78
  96. package/dist/mjs/data-structures/graph/abstract-graph.js +0 -188
  97. package/dist/mjs/data-structures/graph/directed-graph.d.ts +59 -0
  98. package/dist/mjs/data-structures/graph/directed-graph.js +105 -0
  99. package/dist/mjs/data-structures/graph/undirected-graph.d.ts +60 -7
  100. package/dist/mjs/data-structures/graph/undirected-graph.js +127 -19
  101. package/dist/mjs/data-structures/hash/hash-map.d.ts +143 -23
  102. package/dist/mjs/data-structures/hash/hash-map.js +204 -70
  103. package/dist/mjs/data-structures/heap/heap.d.ts +29 -19
  104. package/dist/mjs/data-structures/heap/heap.js +29 -20
  105. package/dist/mjs/data-structures/linked-list/doubly-linked-list.d.ts +71 -25
  106. package/dist/mjs/data-structures/linked-list/doubly-linked-list.js +86 -28
  107. package/dist/mjs/data-structures/linked-list/singly-linked-list.d.ts +26 -3
  108. package/dist/mjs/data-structures/linked-list/singly-linked-list.js +36 -5
  109. package/dist/mjs/data-structures/linked-list/skip-linked-list.d.ts +2 -2
  110. package/dist/mjs/data-structures/linked-list/skip-linked-list.js +2 -2
  111. package/dist/mjs/data-structures/matrix/matrix.d.ts +1 -1
  112. package/dist/mjs/data-structures/matrix/matrix.js +1 -1
  113. package/dist/mjs/data-structures/priority-queue/max-priority-queue.d.ts +10 -0
  114. package/dist/mjs/data-structures/priority-queue/max-priority-queue.js +10 -0
  115. package/dist/mjs/data-structures/priority-queue/min-priority-queue.d.ts +11 -0
  116. package/dist/mjs/data-structures/priority-queue/min-priority-queue.js +11 -0
  117. package/dist/mjs/data-structures/priority-queue/priority-queue.d.ts +8 -0
  118. package/dist/mjs/data-structures/priority-queue/priority-queue.js +8 -0
  119. package/dist/mjs/data-structures/queue/deque.d.ts +95 -21
  120. package/dist/mjs/data-structures/queue/deque.js +105 -21
  121. package/dist/mjs/data-structures/queue/queue.d.ts +65 -45
  122. package/dist/mjs/data-structures/queue/queue.js +65 -45
  123. package/dist/mjs/data-structures/stack/stack.d.ts +36 -22
  124. package/dist/mjs/data-structures/stack/stack.js +36 -22
  125. package/dist/mjs/data-structures/tree/tree.d.ts +57 -3
  126. package/dist/mjs/data-structures/tree/tree.js +80 -14
  127. package/dist/mjs/data-structures/trie/trie.d.ts +100 -36
  128. package/dist/mjs/data-structures/trie/trie.js +118 -39
  129. package/dist/umd/data-structure-typed.js +1445 -595
  130. package/dist/umd/data-structure-typed.min.js +2 -2
  131. package/dist/umd/data-structure-typed.min.js.map +1 -1
  132. package/package.json +59 -58
  133. package/src/data-structures/base/iterable-base.ts +12 -0
  134. package/src/data-structures/binary-tree/avl-tree.ts +37 -3
  135. package/src/data-structures/binary-tree/binary-indexed-tree.ts +22 -0
  136. package/src/data-structures/binary-tree/binary-tree.ts +1 -1
  137. package/src/data-structures/binary-tree/bst.ts +46 -13
  138. package/src/data-structures/binary-tree/rb-tree.ts +79 -18
  139. package/src/data-structures/binary-tree/segment-tree.ts +145 -11
  140. package/src/data-structures/binary-tree/tree-multimap.ts +42 -3
  141. package/src/data-structures/graph/abstract-graph.ts +0 -211
  142. package/src/data-structures/graph/directed-graph.ts +122 -0
  143. package/src/data-structures/graph/undirected-graph.ts +143 -19
  144. package/src/data-structures/hash/hash-map.ts +228 -76
  145. package/src/data-structures/heap/heap.ts +31 -20
  146. package/src/data-structures/linked-list/doubly-linked-list.ts +96 -29
  147. package/src/data-structures/linked-list/singly-linked-list.ts +42 -6
  148. package/src/data-structures/linked-list/skip-linked-list.ts +2 -2
  149. package/src/data-structures/matrix/matrix.ts +1 -1
  150. package/src/data-structures/priority-queue/max-priority-queue.ts +10 -0
  151. package/src/data-structures/priority-queue/min-priority-queue.ts +11 -0
  152. package/src/data-structures/priority-queue/priority-queue.ts +8 -0
  153. package/src/data-structures/queue/deque.ts +118 -22
  154. package/src/data-structures/queue/queue.ts +68 -45
  155. package/src/data-structures/stack/stack.ts +39 -23
  156. package/src/data-structures/tree/tree.ts +89 -15
  157. package/src/data-structures/trie/trie.ts +131 -40
  158. package/test/performance/data-structures/graph/directed-graph.test.ts +1 -1
  159. package/test/unit/data-structures/graph/abstract-graph.test.ts +3 -0
  160. package/test/unit/data-structures/graph/directed-graph.test.ts +189 -253
  161. package/test/unit/data-structures/graph/undirected-graph.test.ts +263 -18
  162. package/test/unit/data-structures/queue/queue.test.ts +2 -0
@@ -755,6 +755,22 @@ var dataStructureTyped = (() => {
755
755
  this.setMany(rawCollection);
756
756
  }
757
757
  }
758
+ /**
759
+ * The function returns the store object, which is a dictionary of HashMapStoreItem objects.
760
+ * @returns The store property is being returned. It is a dictionary-like object with string keys and
761
+ * values of type HashMapStoreItem<K, V>.
762
+ */
763
+ get store() {
764
+ return this._store;
765
+ }
766
+ /**
767
+ * The function returns the object map.
768
+ * @returns The `objMap` property is being returned, which is a `Map` object with keys of type
769
+ * `object` and values of type `V`.
770
+ */
771
+ get objMap() {
772
+ return this._objMap;
773
+ }
758
774
  /**
759
775
  * The function returns the value of the _toEntryFn property.
760
776
  * @returns The function being returned is `this._toEntryFn`.
@@ -762,22 +778,22 @@ var dataStructureTyped = (() => {
762
778
  get toEntryFn() {
763
779
  return this._toEntryFn;
764
780
  }
781
+ /**
782
+ * The function returns the size of an object.
783
+ * @returns The size of the object, which is a number.
784
+ */
785
+ get size() {
786
+ return this._size;
787
+ }
765
788
  /**
766
789
  * The hasFn function is a function that takes in an item and returns a boolean
767
790
  * indicating whether the item is contained within the hash table.
768
791
  *
769
792
  * @return The hash function
770
793
  */
771
- get hasFn() {
794
+ get hashFn() {
772
795
  return this._hashFn;
773
796
  }
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
797
  /**
782
798
  * The function checks if a given element is an array with exactly two elements.
783
799
  * @param {any} rawElement - The `rawElement` parameter is of type `any`, which means it can be any
@@ -814,13 +830,13 @@ var dataStructureTyped = (() => {
814
830
  */
815
831
  set(key, value) {
816
832
  if (this._isObjKey(key)) {
817
- if (!this._objMap.has(key)) {
833
+ if (!this.objMap.has(key)) {
818
834
  this._size++;
819
835
  }
820
- this._objMap.set(key, value);
836
+ this.objMap.set(key, value);
821
837
  } else {
822
838
  const strKey = this._getNoObjKey(key);
823
- if (this._store[strKey] === void 0) {
839
+ if (this.store[strKey] === void 0) {
824
840
  this._size++;
825
841
  }
826
842
  this._store[strKey] = { key, value };
@@ -861,7 +877,7 @@ var dataStructureTyped = (() => {
861
877
  get(key) {
862
878
  var _a;
863
879
  if (this._isObjKey(key)) {
864
- return this._objMap.get(key);
880
+ return this.objMap.get(key);
865
881
  } else {
866
882
  const strKey = this._getNoObjKey(key);
867
883
  return (_a = this._store[strKey]) == null ? void 0 : _a.value;
@@ -875,10 +891,10 @@ var dataStructureTyped = (() => {
875
891
  */
876
892
  has(key) {
877
893
  if (this._isObjKey(key)) {
878
- return this._objMap.has(key);
894
+ return this.objMap.has(key);
879
895
  } else {
880
896
  const strKey = this._getNoObjKey(key);
881
- return strKey in this._store;
897
+ return strKey in this.store;
882
898
  }
883
899
  }
884
900
  /**
@@ -890,20 +906,24 @@ var dataStructureTyped = (() => {
890
906
  */
891
907
  delete(key) {
892
908
  if (this._isObjKey(key)) {
893
- if (this._objMap.has(key)) {
909
+ if (this.objMap.has(key)) {
894
910
  this._size--;
895
911
  }
896
- return this._objMap.delete(key);
912
+ return this.objMap.delete(key);
897
913
  } else {
898
914
  const strKey = this._getNoObjKey(key);
899
- if (strKey in this._store) {
900
- delete this._store[strKey];
915
+ if (strKey in this.store) {
916
+ delete this.store[strKey];
901
917
  this._size--;
902
918
  return true;
903
919
  }
904
920
  return false;
905
921
  }
906
922
  }
923
+ /**
924
+ * Time Complexity: O(n)
925
+ * Space Complexity: O(n)
926
+ */
907
927
  /**
908
928
  * The clone function creates a new HashMap with the same key-value pairs as
909
929
  * this one. The clone function is useful for creating a copy of an existing
@@ -912,7 +932,7 @@ var dataStructureTyped = (() => {
912
932
  * @return A new hashmap with the same values as this one
913
933
  */
914
934
  clone() {
915
- return new _HashMap(this, { hashFn: this._hashFn, toEntryFn: this.toEntryFn });
935
+ return new _HashMap(this, { hashFn: this.hashFn, toEntryFn: this.toEntryFn });
916
936
  }
917
937
  /**
918
938
  * Time Complexity: O(n)
@@ -940,10 +960,6 @@ var dataStructureTyped = (() => {
940
960
  }
941
961
  return resultMap;
942
962
  }
943
- /**
944
- * Time Complexity: O(n)
945
- * Space Complexity: O(n)
946
- */
947
963
  /**
948
964
  * Time Complexity: O(n)
949
965
  * Space Complexity: O(n)
@@ -986,22 +1002,34 @@ var dataStructureTyped = (() => {
986
1002
  * object map.
987
1003
  */
988
1004
  *_getIterator() {
989
- for (const node of Object.values(this._store)) {
1005
+ for (const node of Object.values(this.store)) {
990
1006
  yield [node.key, node.value];
991
1007
  }
992
- for (const node of this._objMap) {
1008
+ for (const node of this.objMap) {
993
1009
  yield node;
994
1010
  }
995
1011
  }
1012
+ /**
1013
+ * The function checks if a given key is an object or a function.
1014
+ * @param {any} key - The parameter "key" can be of any type.
1015
+ * @returns a boolean value.
1016
+ */
996
1017
  _isObjKey(key) {
997
1018
  const keyType = typeof key;
998
1019
  return (keyType === "object" || keyType === "function") && key !== null;
999
1020
  }
1021
+ /**
1022
+ * The function `_getNoObjKey` takes a key and returns a string representation of the key, handling
1023
+ * different types of keys.
1024
+ * @param {K} key - The `key` parameter is of type `K`, which represents the type of the key being
1025
+ * passed to the `_getNoObjKey` function.
1026
+ * @returns a string value.
1027
+ */
1000
1028
  _getNoObjKey(key) {
1001
1029
  const keyType = typeof key;
1002
1030
  let strKey;
1003
1031
  if (keyType !== "string" && keyType !== "number" && keyType !== "symbol") {
1004
- strKey = this._hashFn(key);
1032
+ strKey = this.hashFn(key);
1005
1033
  } else {
1006
1034
  if (keyType === "number") {
1007
1035
  strKey = key;
@@ -1024,11 +1052,13 @@ var dataStructureTyped = (() => {
1024
1052
  */
1025
1053
  constructor(rawCollection = [], options) {
1026
1054
  super();
1055
+ __publicField(this, "_sentinel");
1056
+ __publicField(this, "_hashFn", (key) => String(key));
1057
+ __publicField(this, "_objHashFn", (key) => key);
1027
1058
  __publicField(this, "_noObjMap", {});
1028
1059
  __publicField(this, "_objMap", /* @__PURE__ */ new WeakMap());
1029
1060
  __publicField(this, "_head");
1030
1061
  __publicField(this, "_tail");
1031
- __publicField(this, "_sentinel");
1032
1062
  __publicField(this, "_toEntryFn", (rawElement) => {
1033
1063
  if (this.isEntry(rawElement)) {
1034
1064
  return rawElement;
@@ -1039,8 +1069,6 @@ var dataStructureTyped = (() => {
1039
1069
  }
1040
1070
  });
1041
1071
  __publicField(this, "_size", 0);
1042
- __publicField(this, "_hashFn", (key) => String(key));
1043
- __publicField(this, "_objHashFn", (key) => key);
1044
1072
  this._sentinel = {};
1045
1073
  this._sentinel.prev = this._sentinel.next = this._head = this._tail = this._sentinel;
1046
1074
  if (options) {
@@ -1060,6 +1088,51 @@ var dataStructureTyped = (() => {
1060
1088
  }
1061
1089
  }
1062
1090
  }
1091
+ /**
1092
+ * The function returns the hash function used for generating a hash value for a given key.
1093
+ * @returns The hash function that takes a key of type K and returns a string.
1094
+ */
1095
+ get hashFn() {
1096
+ return this._hashFn;
1097
+ }
1098
+ /**
1099
+ * The function returns the object hash function.
1100
+ * @returns The function `objHashFn` is being returned.
1101
+ */
1102
+ get objHashFn() {
1103
+ return this._objHashFn;
1104
+ }
1105
+ /**
1106
+ * The function returns a record of HashMapLinkedNode objects with string keys.
1107
+ * @returns The method is returning a Record object, which is a TypeScript type that represents an
1108
+ * object with string keys and values that are HashMapLinkedNode objects with keys of type K and
1109
+ * values of type V or undefined.
1110
+ */
1111
+ get noObjMap() {
1112
+ return this._noObjMap;
1113
+ }
1114
+ /**
1115
+ * The function returns the WeakMap object used to map objects to HashMapLinkedNode instances.
1116
+ * @returns The `objMap` property is being returned.
1117
+ */
1118
+ get objMap() {
1119
+ return this._objMap;
1120
+ }
1121
+ /**
1122
+ * The function returns the head node of a HashMapLinkedNode.
1123
+ * @returns The method `getHead()` is returning a `HashMapLinkedNode` object with key type `K` and
1124
+ * value type `V | undefined`.
1125
+ */
1126
+ get head() {
1127
+ return this._head;
1128
+ }
1129
+ /**
1130
+ * The function returns the tail node of a HashMapLinkedNode.
1131
+ * @returns The `_tail` property of type `HashMapLinkedNode<K, V | undefined>` is being returned.
1132
+ */
1133
+ get tail() {
1134
+ return this._tail;
1135
+ }
1063
1136
  /**
1064
1137
  * The function returns the value of the _toEntryFn property.
1065
1138
  * @returns The function being returned is `this._toEntryFn`.
@@ -1074,6 +1147,10 @@ var dataStructureTyped = (() => {
1074
1147
  get size() {
1075
1148
  return this._size;
1076
1149
  }
1150
+ /**
1151
+ * Time Complexity: O(1)
1152
+ * Space Complexity: O(1)
1153
+ */
1077
1154
  /**
1078
1155
  * Time Complexity: O(1)
1079
1156
  * Space Complexity: O(1)
@@ -1085,8 +1162,12 @@ var dataStructureTyped = (() => {
1085
1162
  get first() {
1086
1163
  if (this._size === 0)
1087
1164
  return;
1088
- return [this._head.key, this._head.value];
1165
+ return [this.head.key, this.head.value];
1089
1166
  }
1167
+ /**
1168
+ * Time Complexity: O(1)
1169
+ * Space Complexity: O(1)
1170
+ */
1090
1171
  /**
1091
1172
  * Time Complexity: O(1)
1092
1173
  * Space Complexity: O(1)
@@ -1098,13 +1179,13 @@ var dataStructureTyped = (() => {
1098
1179
  get last() {
1099
1180
  if (this._size === 0)
1100
1181
  return;
1101
- return [this._tail.key, this._tail.value];
1182
+ return [this.tail.key, this.tail.value];
1102
1183
  }
1103
1184
  /**
1104
1185
  * The `begin()` function in TypeScript iterates over a linked list and yields key-value pairs.
1105
1186
  */
1106
1187
  *begin() {
1107
- let node = this._head;
1188
+ let node = this.head;
1108
1189
  while (node !== this._sentinel) {
1109
1190
  yield [node.key, node.value];
1110
1191
  node = node.next;
@@ -1115,12 +1196,16 @@ var dataStructureTyped = (() => {
1115
1196
  * key and value.
1116
1197
  */
1117
1198
  *reverseBegin() {
1118
- let node = this._tail;
1199
+ let node = this.tail;
1119
1200
  while (node !== this._sentinel) {
1120
1201
  yield [node.key, node.value];
1121
1202
  node = node.prev;
1122
1203
  }
1123
1204
  }
1205
+ /**
1206
+ * Time Complexity: O(1)
1207
+ * Space Complexity: O(1)
1208
+ */
1124
1209
  /**
1125
1210
  * Time Complexity: O(1)
1126
1211
  * Space Complexity: O(1)
@@ -1137,19 +1222,19 @@ var dataStructureTyped = (() => {
1137
1222
  let node;
1138
1223
  const isNewKey = !this.has(key);
1139
1224
  if (isWeakKey(key)) {
1140
- const hash = this._objHashFn(key);
1141
- node = this._objMap.get(hash);
1225
+ const hash = this.objHashFn(key);
1226
+ node = this.objMap.get(hash);
1142
1227
  if (!node && isNewKey) {
1143
- node = { key: hash, value, prev: this._tail, next: this._sentinel };
1144
- this._objMap.set(hash, node);
1228
+ node = { key: hash, value, prev: this.tail, next: this._sentinel };
1229
+ this.objMap.set(hash, node);
1145
1230
  } else if (node) {
1146
1231
  node.value = value;
1147
1232
  }
1148
1233
  } else {
1149
- const hash = this._hashFn(key);
1150
- node = this._noObjMap[hash];
1234
+ const hash = this.hashFn(key);
1235
+ node = this.noObjMap[hash];
1151
1236
  if (!node && isNewKey) {
1152
- this._noObjMap[hash] = node = { key, value, prev: this._tail, next: this._sentinel };
1237
+ this.noObjMap[hash] = node = { key, value, prev: this.tail, next: this._sentinel };
1153
1238
  } else if (node) {
1154
1239
  node.value = value;
1155
1240
  }
@@ -1159,8 +1244,8 @@ var dataStructureTyped = (() => {
1159
1244
  this._head = node;
1160
1245
  this._sentinel.next = node;
1161
1246
  } else {
1162
- this._tail.next = node;
1163
- node.prev = this._tail;
1247
+ this.tail.next = node;
1248
+ node.prev = this.tail;
1164
1249
  }
1165
1250
  this._tail = node;
1166
1251
  this._sentinel.prev = node;
@@ -1192,13 +1277,17 @@ var dataStructureTyped = (() => {
1192
1277
  */
1193
1278
  has(key) {
1194
1279
  if (isWeakKey(key)) {
1195
- const hash = this._objHashFn(key);
1196
- return this._objMap.has(hash);
1280
+ const hash = this.objHashFn(key);
1281
+ return this.objMap.has(hash);
1197
1282
  } else {
1198
- const hash = this._hashFn(key);
1199
- return hash in this._noObjMap;
1283
+ const hash = this.hashFn(key);
1284
+ return hash in this.noObjMap;
1200
1285
  }
1201
1286
  }
1287
+ /**
1288
+ * Time Complexity: O(1)
1289
+ * Space Complexity: O(1)
1290
+ */
1202
1291
  /**
1203
1292
  * Time Complexity: O(1)
1204
1293
  * Space Complexity: O(1)
@@ -1214,89 +1303,109 @@ var dataStructureTyped = (() => {
1214
1303
  */
1215
1304
  get(key) {
1216
1305
  if (isWeakKey(key)) {
1217
- const hash = this._objHashFn(key);
1218
- const node = this._objMap.get(hash);
1306
+ const hash = this.objHashFn(key);
1307
+ const node = this.objMap.get(hash);
1219
1308
  return node ? node.value : void 0;
1220
1309
  } else {
1221
- const hash = this._hashFn(key);
1222
- const node = this._noObjMap[hash];
1310
+ const hash = this.hashFn(key);
1311
+ const node = this.noObjMap[hash];
1223
1312
  return node ? node.value : void 0;
1224
1313
  }
1225
1314
  }
1226
1315
  /**
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
- */
1316
+ * Time Complexity: O(n)
1317
+ * Space Complexity: O(1)
1318
+ * /
1319
+
1320
+ /**
1321
+ * Time Complexity: O(n)
1322
+ * Space Complexity: O(1)
1323
+ *
1324
+ * The function `at` retrieves the key-value pair at a specified index in a linked list.
1325
+ * @param {number} index - The index parameter is a number that represents the position of the
1326
+ * element we want to retrieve from the data structure.
1327
+ * @returns The method `at(index: number)` is returning an array containing the key-value pair at
1328
+ * the specified index in the data structure. The key-value pair is represented as a tuple `[K, V]`,
1329
+ * where `K` is the key and `V` is the value.
1330
+ */
1237
1331
  at(index) {
1238
1332
  rangeCheck(index, 0, this._size - 1);
1239
- let node = this._head;
1333
+ let node = this.head;
1240
1334
  while (index--) {
1241
1335
  node = node.next;
1242
1336
  }
1243
1337
  return node.value;
1244
1338
  }
1245
1339
  /**
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
- */
1340
+ * Time Complexity: O(1)
1341
+ * Space Complexity: O(1)
1342
+ * /
1343
+
1344
+ /**
1345
+ * Time Complexity: O(1)
1346
+ * Space Complexity: O(1)
1347
+ *
1348
+ * The `delete` function removes a key-value pair from a map-like data structure.
1349
+ * @param {K} key - The `key` parameter is the key that you want to delete from the data structure.
1350
+ * It can be of any type, but typically it is a string or an object.
1351
+ * @returns a boolean value. It returns `true` if the deletion was successful, and `false` if the key
1352
+ * was not found.
1353
+ */
1255
1354
  delete(key) {
1256
1355
  let node;
1257
1356
  if (isWeakKey(key)) {
1258
- const hash = this._objHashFn(key);
1259
- node = this._objMap.get(hash);
1357
+ const hash = this.objHashFn(key);
1358
+ node = this.objMap.get(hash);
1260
1359
  if (!node) {
1261
1360
  return false;
1262
1361
  }
1263
- this._objMap.delete(hash);
1362
+ this.objMap.delete(hash);
1264
1363
  } else {
1265
- const hash = this._hashFn(key);
1266
- node = this._noObjMap[hash];
1364
+ const hash = this.hashFn(key);
1365
+ node = this.noObjMap[hash];
1267
1366
  if (!node) {
1268
1367
  return false;
1269
1368
  }
1270
- delete this._noObjMap[hash];
1369
+ delete this.noObjMap[hash];
1271
1370
  }
1272
1371
  this._deleteNode(node);
1273
1372
  return true;
1274
1373
  }
1275
1374
  /**
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
- */
1375
+ * Time Complexity: O(n)
1376
+ * Space Complexity: O(1)
1377
+ * /
1378
+
1379
+ /**
1380
+ * Time Complexity: O(n)
1381
+ * Space Complexity: O(1)
1382
+ *
1383
+ * The `deleteAt` function deletes a node at a specified index in a linked list.
1384
+ * @param {number} index - The index parameter represents the position at which the node should be
1385
+ * deleted in the linked list.
1386
+ * @returns The size of the list after deleting the element at the specified index.
1387
+ */
1284
1388
  deleteAt(index) {
1285
1389
  rangeCheck(index, 0, this._size - 1);
1286
- let node = this._head;
1390
+ let node = this.head;
1287
1391
  while (index--) {
1288
1392
  node = node.next;
1289
1393
  }
1290
1394
  return this._deleteNode(node);
1291
1395
  }
1292
1396
  /**
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
- */
1397
+ * Time Complexity: O(1)
1398
+ * Space Complexity: O(1)
1399
+ * /
1400
+
1401
+ /**
1402
+ * Time Complexity: O(1)
1403
+ * Space Complexity: O(1)
1404
+ *
1405
+ * The function checks if a data structure is empty by comparing its size to zero.
1406
+ * @returns The method is returning a boolean value indicating whether the size of the object is 0 or
1407
+ * not.
1408
+ */
1300
1409
  isEmpty() {
1301
1410
  return this._size === 0;
1302
1411
  }
@@ -1310,11 +1419,16 @@ var dataStructureTyped = (() => {
1310
1419
  return Array.isArray(rawElement) && rawElement.length === 2;
1311
1420
  }
1312
1421
  /**
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
- */
1422
+ * Time Complexity: O(1)
1423
+ * Space Complexity: O(1)
1424
+ * /
1425
+
1426
+ /**
1427
+ * Time Complexity: O(1)
1428
+ * Space Complexity: O(1)
1429
+ *
1430
+ * The `clear` function clears all the entries in a data structure and resets its properties.
1431
+ */
1318
1432
  clear() {
1319
1433
  this._noObjMap = {};
1320
1434
  this._size = 0;
@@ -1334,7 +1448,7 @@ var dataStructureTyped = (() => {
1334
1448
  * of the original `LinkedHashMap` object.
1335
1449
  */
1336
1450
  clone() {
1337
- const cloned = new _LinkedHashMap([], { hashFn: this._hashFn, objHashFn: this._objHashFn });
1451
+ const cloned = new _LinkedHashMap([], { hashFn: this.hashFn, objHashFn: this.objHashFn });
1338
1452
  for (const entry of this) {
1339
1453
  const [key, value] = entry;
1340
1454
  cloned.set(key, value);
@@ -1342,20 +1456,25 @@ var dataStructureTyped = (() => {
1342
1456
  return cloned;
1343
1457
  }
1344
1458
  /**
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
- */
1459
+ * Time Complexity: O(n)
1460
+ * Space Complexity: O(n)
1461
+ * /
1462
+
1463
+ /**
1464
+ * Time Complexity: O(n)
1465
+ * Space Complexity: O(n)
1466
+ *
1467
+ * The `filter` function creates a new `LinkedHashMap` containing key-value pairs from the original
1468
+ * map that satisfy a given predicate function.
1469
+ * @param predicate - The `predicate` parameter is a callback function that takes four arguments:
1470
+ * `value`, `key`, `index`, and `this`. It should return a boolean value indicating whether the
1471
+ * current element should be included in the filtered map or not.
1472
+ * @param {any} [thisArg] - The `thisArg` parameter is an optional argument that allows you to
1473
+ * specify the value of `this` within the `predicate` function. It is used when you want to bind a
1474
+ * specific object as the context for the `predicate` function. If `thisArg` is not provided, `this
1475
+ * @returns a new `LinkedHashMap` object that contains the key-value pairs from the original
1476
+ * `LinkedHashMap` object that satisfy the given predicate function.
1477
+ */
1359
1478
  filter(predicate, thisArg) {
1360
1479
  const filteredMap = new _LinkedHashMap();
1361
1480
  let index = 0;
@@ -1368,22 +1487,27 @@ var dataStructureTyped = (() => {
1368
1487
  return filteredMap;
1369
1488
  }
1370
1489
  /**
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
- */
1490
+ * Time Complexity: O(n)
1491
+ * Space Complexity: O(n)
1492
+ * /
1493
+
1494
+ /**
1495
+ * Time Complexity: O(n)
1496
+ * Space Complexity: O(n)
1497
+ *
1498
+ * The `map` function in TypeScript creates a new `LinkedHashMap` by applying a callback function to
1499
+ * each key-value pair in the original map.
1500
+ * @param callback - The callback parameter is a function that will be called for each key-value pair
1501
+ * in the map. It takes four arguments: the value of the current key-value pair, the key of the
1502
+ * current key-value pair, the index of the current key-value pair, and the map itself. The callback
1503
+ * function should
1504
+ * @param {any} [thisArg] - The `thisArg` parameter is an optional argument that allows you to
1505
+ * specify the value of `this` within the callback function. If provided, the callback function will
1506
+ * be called with `thisArg` as its `this` value. If not provided, `this` will refer to the current
1507
+ * map
1508
+ * @returns a new `LinkedHashMap` object with the values mapped according to the provided callback
1509
+ * function.
1510
+ */
1387
1511
  map(callback, thisArg) {
1388
1512
  const mappedMap = new _LinkedHashMap();
1389
1513
  let index = 0;
@@ -1413,19 +1537,29 @@ var dataStructureTyped = (() => {
1413
1537
  return this.set(key, value);
1414
1538
  }
1415
1539
  /**
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
- */
1540
+ * Time Complexity: O(n)
1541
+ * Space Complexity: O(1)
1542
+ * where n is the number of entries in the LinkedHashMap.
1543
+ * /
1544
+
1545
+ /**
1546
+ * Time Complexity: O(n)
1547
+ * Space Complexity: O(1)
1548
+ * where n is the number of entries in the LinkedHashMap.
1549
+ *
1550
+ * The above function is an iterator that yields key-value pairs from a linked list.
1551
+ */
1422
1552
  *_getIterator() {
1423
- let node = this._head;
1553
+ let node = this.head;
1424
1554
  while (node !== this._sentinel) {
1425
1555
  yield [node.key, node.value];
1426
1556
  node = node.next;
1427
1557
  }
1428
1558
  }
1559
+ /**
1560
+ * Time Complexity: O(1)
1561
+ * Space Complexity: O(1)
1562
+ */
1429
1563
  /**
1430
1564
  * Time Complexity: O(1)
1431
1565
  * Space Complexity: O(1)
@@ -1440,10 +1574,10 @@ var dataStructureTyped = (() => {
1440
1574
  const { prev, next } = node;
1441
1575
  prev.next = next;
1442
1576
  next.prev = prev;
1443
- if (node === this._head) {
1577
+ if (node === this.head) {
1444
1578
  this._head = next;
1445
1579
  }
1446
- if (node === this._tail) {
1580
+ if (node === this.tail) {
1447
1581
  this._tail = prev;
1448
1582
  }
1449
1583
  this._size -= 1;
@@ -1459,10 +1593,41 @@ var dataStructureTyped = (() => {
1459
1593
  * will be stored in the node of a linked list.
1460
1594
  */
1461
1595
  constructor(value) {
1462
- __publicField(this, "value");
1463
- __publicField(this, "next");
1464
- this.value = value;
1465
- this.next = void 0;
1596
+ __publicField(this, "_value");
1597
+ __publicField(this, "_next");
1598
+ this._value = value;
1599
+ this._next = void 0;
1600
+ }
1601
+ /**
1602
+ * The function returns the value of a protected variable.
1603
+ * @returns The value of the variable `_value` is being returned.
1604
+ */
1605
+ get value() {
1606
+ return this._value;
1607
+ }
1608
+ /**
1609
+ * The above function sets the value of a variable.
1610
+ * @param {E} value - The parameter "value" is of type E, which means it can be any type.
1611
+ */
1612
+ set value(value) {
1613
+ this._value = value;
1614
+ }
1615
+ /**
1616
+ * The `next` function returns the next node in a singly linked list.
1617
+ * @returns The `next` property is being returned. It can be either a `SinglyLinkedListNode<E>`
1618
+ * object or `undefined`.
1619
+ */
1620
+ get next() {
1621
+ return this._next;
1622
+ }
1623
+ /**
1624
+ * The "next" property of a SinglyLinkedListNode is set to the provided value.
1625
+ * @param {SinglyLinkedListNode<E> | undefined} value - The `value` parameter is of type
1626
+ * `SinglyLinkedListNode<E> | undefined`. This means that it can accept either a
1627
+ * `SinglyLinkedListNode` object or `undefined` as its value.
1628
+ */
1629
+ set next(value) {
1630
+ this._next = value;
1466
1631
  }
1467
1632
  };
1468
1633
  var SinglyLinkedList = class _SinglyLinkedList extends IterableElementBase {
@@ -2103,7 +2268,7 @@ var dataStructureTyped = (() => {
2103
2268
  return filteredList;
2104
2269
  }
2105
2270
  /**
2106
- * Time Complexity: O(n), where n is the number of elements in the linked list.
2271
+ * Time Complexity: O(n)
2107
2272
  * Space Complexity: O(n)
2108
2273
  */
2109
2274
  /**
@@ -2149,12 +2314,60 @@ var dataStructureTyped = (() => {
2149
2314
  * is defined as a generic type "E".
2150
2315
  */
2151
2316
  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;
2317
+ __publicField(this, "_value");
2318
+ __publicField(this, "_next");
2319
+ __publicField(this, "_prev");
2320
+ this._value = value;
2321
+ this._next = void 0;
2322
+ this._prev = void 0;
2323
+ }
2324
+ /**
2325
+ * The function returns the value of a protected variable.
2326
+ * @returns The value of the variable `_value` is being returned.
2327
+ */
2328
+ get value() {
2329
+ return this._value;
2330
+ }
2331
+ /**
2332
+ * The above function sets the value of a variable.
2333
+ * @param {E} value - The parameter "value" is of type E, which means it can be any type.
2334
+ */
2335
+ set value(value) {
2336
+ this._value = value;
2337
+ }
2338
+ /**
2339
+ * The "next" function returns the next node in a doubly linked list.
2340
+ * @returns The `next` property is being returned. It can be either a `DoublyLinkedListNode<E>`
2341
+ * object or `undefined`.
2342
+ */
2343
+ get next() {
2344
+ return this._next;
2345
+ }
2346
+ /**
2347
+ * The "next" property of a DoublyLinkedListNode is set to the provided value.
2348
+ * @param {DoublyLinkedListNode<E> | undefined} value - The `value` parameter is of type
2349
+ * `DoublyLinkedListNode<E> | undefined`. This means that it can accept either a
2350
+ * `DoublyLinkedListNode` object or `undefined` as its value.
2351
+ */
2352
+ set next(value) {
2353
+ this._next = value;
2354
+ }
2355
+ /**
2356
+ * The `prev` function returns the previous node in a doubly linked list.
2357
+ * @returns The `prev` property of the `DoublyLinkedListNode` class is being returned. It can either
2358
+ * be a `DoublyLinkedListNode` object or `undefined`.
2359
+ */
2360
+ get prev() {
2361
+ return this._prev;
2362
+ }
2363
+ /**
2364
+ * The function sets the previous node of a doubly linked list node.
2365
+ * @param {DoublyLinkedListNode<E> | undefined} value - The `value` parameter is of type
2366
+ * `DoublyLinkedListNode<E> | undefined`. This means that it can accept either a
2367
+ * `DoublyLinkedListNode` object or `undefined` as its value.
2368
+ */
2369
+ set prev(value) {
2370
+ this._prev = value;
2158
2371
  }
2159
2372
  };
2160
2373
  var DoublyLinkedList = class _DoublyLinkedList extends IterableElementBase {
@@ -2201,12 +2414,12 @@ var dataStructureTyped = (() => {
2201
2414
  return this._size;
2202
2415
  }
2203
2416
  /**
2204
- * Time Complexity: O(n)
2205
- * Space Complexity: O(n)
2417
+ * Time Complexity: O(1)
2418
+ * Space Complexity: O(1)
2206
2419
  * where n is the number of elements in the linked list.
2207
2420
  */
2208
2421
  /**
2209
- * Time Complexity: O(n)
2422
+ * Time Complexity: O(1)
2210
2423
  * Space Complexity: O(1)
2211
2424
  *
2212
2425
  * The `get first` function returns the first node in a doubly linked list, or undefined if the list is empty.
@@ -2221,7 +2434,7 @@ var dataStructureTyped = (() => {
2221
2434
  * Space Complexity: O(1)
2222
2435
  */
2223
2436
  /**
2224
- * Time Complexity: O(n)
2437
+ * Time Complexity: O(1)
2225
2438
  * Space Complexity: O(1)
2226
2439
  *
2227
2440
  * The `get last` function returns the last node in a doubly linked list, or undefined if the list is empty.
@@ -2232,11 +2445,11 @@ var dataStructureTyped = (() => {
2232
2445
  return (_a = this.tail) == null ? void 0 : _a.value;
2233
2446
  }
2234
2447
  /**
2235
- * Time Complexity: O(1)
2236
- * Space Complexity: O(1)
2448
+ * Time Complexity: O(n)
2449
+ * Space Complexity: O(n)
2237
2450
  */
2238
2451
  /**
2239
- * Time Complexity: O(n), where n is the size of the input array.
2452
+ * Time Complexity: O(n)
2240
2453
  * Space Complexity: O(n)
2241
2454
  *
2242
2455
  * The `fromArray` function creates a new instance of a DoublyLinkedList and populates it with the elements from the
@@ -2298,7 +2511,7 @@ var dataStructureTyped = (() => {
2298
2511
  return removedNode.value;
2299
2512
  }
2300
2513
  /**
2301
- * Time Complexity: O(n)
2514
+ * Time Complexity: O(1)
2302
2515
  * Space Complexity: O(1)
2303
2516
  */
2304
2517
  /**
@@ -2324,7 +2537,7 @@ var dataStructureTyped = (() => {
2324
2537
  return removedNode.value;
2325
2538
  }
2326
2539
  /**
2327
- * Time Complexity: O(n)
2540
+ * Time Complexity: O(1)
2328
2541
  * Space Complexity: O(1)
2329
2542
  */
2330
2543
  /**
@@ -2457,12 +2670,12 @@ var dataStructureTyped = (() => {
2457
2670
  return true;
2458
2671
  }
2459
2672
  /**
2460
- * Time Complexity: O(n)
2673
+ * Time Complexity: O(1) or O(n)
2461
2674
  * Space Complexity: O(1)
2462
2675
  * where n is the number of elements in the linked list.
2463
2676
  */
2464
2677
  /**
2465
- * Time Complexity: O(n)
2678
+ * Time Complexity: O(1) or O(n)
2466
2679
  * Space Complexity: O(1)
2467
2680
  *
2468
2681
  * The `addBefore` function inserts a new value before an existing value or node in a doubly linked list.
@@ -2498,11 +2711,11 @@ var dataStructureTyped = (() => {
2498
2711
  return false;
2499
2712
  }
2500
2713
  /**
2501
- * Time Complexity: O(n)
2714
+ * Time Complexity: O(1) or O(n)
2502
2715
  * Space Complexity: O(1)
2503
2716
  */
2504
2717
  /**
2505
- * Time Complexity: O(n)
2718
+ * Time Complexity: O(1) or O(n)
2506
2719
  * Space Complexity: O(1)
2507
2720
  *
2508
2721
  * The `addAfter` function inserts a new node with a given value after an existing node in a doubly linked list.
@@ -2566,7 +2779,11 @@ var dataStructureTyped = (() => {
2566
2779
  return true;
2567
2780
  }
2568
2781
  /**
2569
- * Time Complexity: O(n)
2782
+ * Time Complexity: O(1) or O(n)
2783
+ * Space Complexity: O(1)
2784
+ */
2785
+ /**
2786
+ * Time Complexity: O(1) or O(n)
2570
2787
  * Space Complexity: O(1)
2571
2788
  *
2572
2789
  * The `delete` function removes a node from a doubly linked list based on either the node itself or its value.
@@ -2603,6 +2820,9 @@ var dataStructureTyped = (() => {
2603
2820
  * Space Complexity: O(1)
2604
2821
  */
2605
2822
  /**
2823
+ * Time Complexity: O(1)
2824
+ * Space Complexity: O(1)
2825
+ *
2606
2826
  * The function checks if a variable has a size greater than zero and returns a boolean value.
2607
2827
  * @returns A boolean value is being returned.
2608
2828
  */
@@ -2614,6 +2834,9 @@ var dataStructureTyped = (() => {
2614
2834
  * Space Complexity: O(1)
2615
2835
  */
2616
2836
  /**
2837
+ * Time Complexity: O(1)
2838
+ * Space Complexity: O(1)
2839
+ *
2617
2840
  * The `clear` function resets the linked list by setting the head, tail, and size to undefined and 0 respectively.
2618
2841
  */
2619
2842
  clear() {
@@ -2649,7 +2872,7 @@ var dataStructureTyped = (() => {
2649
2872
  }
2650
2873
  /**
2651
2874
  * Time Complexity: O(n)
2652
- * Space Complexity: O(n)
2875
+ * Space Complexity: O(1)
2653
2876
  */
2654
2877
  /**
2655
2878
  * Time Complexity: O(n)
@@ -2674,7 +2897,7 @@ var dataStructureTyped = (() => {
2674
2897
  }
2675
2898
  /**
2676
2899
  * Time Complexity: O(n)
2677
- * Space Complexity: O(n)
2900
+ * Space Complexity: O(1)
2678
2901
  */
2679
2902
  /**
2680
2903
  * Time Complexity: O(n)
@@ -2749,8 +2972,8 @@ var dataStructureTyped = (() => {
2749
2972
  return new _DoublyLinkedList(this.values());
2750
2973
  }
2751
2974
  /**
2752
- * Time Complexity: O(1)
2753
- * Space Complexity: O(1)
2975
+ * Time Complexity: O(n)
2976
+ * Space Complexity: O(n)
2754
2977
  */
2755
2978
  /**
2756
2979
  * Time Complexity: O(n)
@@ -2781,8 +3004,8 @@ var dataStructureTyped = (() => {
2781
3004
  return filteredList;
2782
3005
  }
2783
3006
  /**
2784
- * Time Complexity: O(1)
2785
- * Space Complexity: O(1)
3007
+ * Time Complexity: O(n)
3008
+ * Space Complexity: O(n)
2786
3009
  */
2787
3010
  /**
2788
3011
  * Time Complexity: O(n)
@@ -2840,7 +3063,7 @@ var dataStructureTyped = (() => {
2840
3063
  return this.pop();
2841
3064
  }
2842
3065
  /**
2843
- * Time Complexity: O(n)
3066
+ * Time Complexity: O(1)
2844
3067
  * Space Complexity: O(1)
2845
3068
  */
2846
3069
  /**
@@ -2855,7 +3078,7 @@ var dataStructureTyped = (() => {
2855
3078
  return this.shift();
2856
3079
  }
2857
3080
  /**
2858
- * Time Complexity: O(n)
3081
+ * Time Complexity: O(1)
2859
3082
  * Space Complexity: O(1)
2860
3083
  */
2861
3084
  /**
@@ -2926,7 +3149,7 @@ var dataStructureTyped = (() => {
2926
3149
  return this._head;
2927
3150
  }
2928
3151
  /**
2929
- * The function returns the value of the private variable _level.
3152
+ * The function returns the value of the protected variable _level.
2930
3153
  * @returns The level property of the object.
2931
3154
  */
2932
3155
  get level() {
@@ -2941,7 +3164,7 @@ var dataStructureTyped = (() => {
2941
3164
  }
2942
3165
  /**
2943
3166
  * The function returns the probability value.
2944
- * @returns The probability value stored in the private variable `_probability` is being returned.
3167
+ * @returns The probability value stored in the protected variable `_probability` is being returned.
2945
3168
  */
2946
3169
  get probability() {
2947
3170
  return this._probability;
@@ -3179,10 +3402,6 @@ var dataStructureTyped = (() => {
3179
3402
  get elements() {
3180
3403
  return this._elements;
3181
3404
  }
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
3405
  /**
3187
3406
  * The size() function returns the number of elements in an array.
3188
3407
  * @returns The size of the elements array.
@@ -3191,8 +3410,12 @@ var dataStructureTyped = (() => {
3191
3410
  return this.elements.length;
3192
3411
  }
3193
3412
  /**
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.
3413
+ * Time Complexity: O(n)
3414
+ * Space Complexity: O(n)
3415
+ */
3416
+ /**
3417
+ * Time Complexity: O(n)
3418
+ * Space Complexity: O(n)
3196
3419
  *
3197
3420
  * The function "fromArray" creates a new Stack object from an array of elements.
3198
3421
  * @param {E[]} elements - The `elements` parameter is an array of elements of type `E`.
@@ -3210,12 +3433,12 @@ var dataStructureTyped = (() => {
3210
3433
  return this.elements.length === 0;
3211
3434
  }
3212
3435
  /**
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.
3436
+ * Time Complexity: O(1)
3437
+ * Space Complexity: O(1)
3215
3438
  */
3216
3439
  /**
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.
3440
+ * Time Complexity: O(1)
3441
+ * Space Complexity: O(1)
3219
3442
  *
3220
3443
  * The `peek` function returns the last element of an array, or undefined if the array is empty.
3221
3444
  * @returns The `peek()` function returns the last element of the `_elements` array, or `undefined` if the array is empty.
@@ -3226,12 +3449,12 @@ var dataStructureTyped = (() => {
3226
3449
  return this.elements[this.elements.length - 1];
3227
3450
  }
3228
3451
  /**
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.
3452
+ * Time Complexity: O(1)
3453
+ * Space Complexity: O(1)
3231
3454
  */
3232
3455
  /**
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.
3456
+ * Time Complexity: O(1)
3457
+ * Space Complexity: O(1)
3235
3458
  *
3236
3459
  * The push function adds an element to the stack and returns the updated stack.
3237
3460
  * @param {E} element - The parameter "element" is of type E, which means it can be any data type.
@@ -3242,12 +3465,12 @@ var dataStructureTyped = (() => {
3242
3465
  return true;
3243
3466
  }
3244
3467
  /**
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.
3468
+ * Time Complexity: O(1)
3469
+ * Space Complexity: O(1)
3247
3470
  */
3248
3471
  /**
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.
3472
+ * Time Complexity: O(1)
3473
+ * Space Complexity: O(1)
3251
3474
  *
3252
3475
  * The `pop` function removes and returns the last element from an array, or returns undefined if the array is empty.
3253
3476
  * @returns The `pop()` method is returning the last element of the array `_elements` if the array is not empty. If the
@@ -3291,18 +3514,25 @@ var dataStructureTyped = (() => {
3291
3514
  return this.elements.slice();
3292
3515
  }
3293
3516
  /**
3517
+ * Time Complexity: O(1)
3518
+ * Space Complexity: O(1)
3519
+ */
3520
+ /**
3521
+ * Time Complexity: O(1)
3522
+ * Space Complexity: O(1)
3523
+ *
3294
3524
  * The clear function clears the elements array.
3295
3525
  */
3296
3526
  clear() {
3297
3527
  this._elements = [];
3298
3528
  }
3299
3529
  /**
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.
3530
+ * Time Complexity: O(n)
3531
+ * Space Complexity: O(n)
3302
3532
  */
3303
3533
  /**
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.
3534
+ * Time Complexity: O(n)
3535
+ * Space Complexity: O(n)
3306
3536
  *
3307
3537
  * The `clone()` function returns a new `Stack` object with the same elements as the original stack.
3308
3538
  * @returns The `clone()` method is returning a new `Stack` object with a copy of the `_elements` array.
@@ -3368,6 +3598,13 @@ var dataStructureTyped = (() => {
3368
3598
  return newStack;
3369
3599
  }
3370
3600
  /**
3601
+ * Time Complexity: O(n)
3602
+ * Space Complexity: O(n)
3603
+ */
3604
+ /**
3605
+ * Time Complexity: O(n)
3606
+ * Space Complexity: O(n)
3607
+ *
3371
3608
  * Custom iterator for the Stack class.
3372
3609
  * @returns An iterator object.
3373
3610
  */
@@ -3404,7 +3641,7 @@ var dataStructureTyped = (() => {
3404
3641
  }
3405
3642
  /**
3406
3643
  * The offset function returns the offset of the current page.
3407
- * @return The value of the private variable _offset
3644
+ * @return The value of the protected variable _offset
3408
3645
  */
3409
3646
  get offset() {
3410
3647
  return this._offset;
@@ -3417,8 +3654,12 @@ var dataStructureTyped = (() => {
3417
3654
  return this.elements.length - this.offset;
3418
3655
  }
3419
3656
  /**
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.
3657
+ * Time Complexity: O(1)
3658
+ * Space Complexity: O(1)
3659
+ */
3660
+ /**
3661
+ * Time Complexity: O(1)
3662
+ * Space Complexity: O(1)
3422
3663
  *
3423
3664
  * The `first` function returns the first element of the array `_elements` if it exists, otherwise it returns `undefined`.
3424
3665
  * @returns The `get first()` method returns the first element of the data structure, represented by the `_elements` array at
@@ -3428,12 +3669,12 @@ var dataStructureTyped = (() => {
3428
3669
  return this.size > 0 ? this.elements[this.offset] : void 0;
3429
3670
  }
3430
3671
  /**
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.
3672
+ * Time Complexity: O(1)
3673
+ * Space Complexity: O(1)
3433
3674
  */
3434
3675
  /**
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.
3676
+ * Time Complexity: O(1)
3677
+ * Space Complexity: O(1)
3437
3678
  *
3438
3679
  * The `last` function returns the last element in an array-like data structure, or undefined if the structure is empty.
3439
3680
  * @returns The method `get last()` returns the last element of the `_elements` array if the array is not empty. If the
@@ -3443,10 +3684,13 @@ var dataStructureTyped = (() => {
3443
3684
  return this.size > 0 ? this.elements[this.elements.length - 1] : void 0;
3444
3685
  }
3445
3686
  /**
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.
3687
+ * Time Complexity: O(n)
3688
+ * Space Complexity: O(n)
3448
3689
  */
3449
3690
  /**
3691
+ * Time Complexity: O(n)
3692
+ * Space Complexity: O(n)
3693
+ *
3450
3694
  * The function "fromArray" creates a new Queue object from an array of elements.Creates a queue from an existing array.
3451
3695
  * @public
3452
3696
  * @static
@@ -3458,12 +3702,12 @@ var dataStructureTyped = (() => {
3458
3702
  return new _Queue(elements);
3459
3703
  }
3460
3704
  /**
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.
3705
+ * Time Complexity: O(1)
3706
+ * Space Complexity: O(1)
3463
3707
  */
3464
3708
  /**
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.
3709
+ * Time Complexity: O(1)
3710
+ * Space Complexity: O(1)
3467
3711
  *
3468
3712
  * 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
3713
  * @param {E} element - The `element` parameter represents the element that you want to add to the queue.
@@ -3474,12 +3718,12 @@ var dataStructureTyped = (() => {
3474
3718
  return true;
3475
3719
  }
3476
3720
  /**
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.
3721
+ * Time Complexity: O(1)
3722
+ * Space Complexity: O(1)
3479
3723
  */
3480
3724
  /**
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.
3725
+ * Time Complexity: O(1)
3726
+ * Space Complexity: O(1)
3483
3727
  *
3484
3728
  * The `shift` function removes and returns the first element in the queue, and adjusts the internal data structure if
3485
3729
  * necessary to optimize performance.
@@ -3515,12 +3759,12 @@ var dataStructureTyped = (() => {
3515
3759
  return spliced.length === 1;
3516
3760
  }
3517
3761
  /**
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.
3762
+ * Time Complexity: O(1)
3763
+ * Space Complexity: O(1)
3520
3764
  */
3521
3765
  /**
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.
3766
+ * Time Complexity: O(1)
3767
+ * Space Complexity: O(1)
3524
3768
  *
3525
3769
  * The `peek` function returns the first element of the array `_elements` if it exists, otherwise it returns `undefined`.
3526
3770
  * @returns The `peek()` method returns the first element of the data structure, represented by the `_elements` array at
@@ -3530,12 +3774,12 @@ var dataStructureTyped = (() => {
3530
3774
  return this.first;
3531
3775
  }
3532
3776
  /**
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.
3777
+ * Time Complexity: O(1)
3778
+ * Space Complexity: O(1)
3535
3779
  */
3536
3780
  /**
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.
3781
+ * Time Complexity: O(1)
3782
+ * Space Complexity: O(1)
3539
3783
  *
3540
3784
  * The `peekLast` function returns the last element in an array-like data structure, or undefined if the structure is empty.
3541
3785
  * @returns The method `peekLast()` returns the last element of the `_elements` array if the array is not empty. If the
@@ -3545,12 +3789,12 @@ var dataStructureTyped = (() => {
3545
3789
  return this.last;
3546
3790
  }
3547
3791
  /**
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.
3792
+ * Time Complexity: O(1)
3793
+ * Space Complexity: O(1)
3550
3794
  */
3551
3795
  /**
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.
3796
+ * Time Complexity: O(1)
3797
+ * Space Complexity: O(1)
3554
3798
  *
3555
3799
  * The enqueue function adds a value to the end of a queue.
3556
3800
  * @param {E} value - The value parameter represents the value that you want to add to the queue.
@@ -3559,12 +3803,12 @@ var dataStructureTyped = (() => {
3559
3803
  return this.push(value);
3560
3804
  }
3561
3805
  /**
3562
- * Time Complexity: O(n) - same as shift().
3563
- * Space Complexity: O(1) - same as shift().
3806
+ * Time Complexity: O(1)
3807
+ * Space Complexity: O(1)
3564
3808
  */
3565
3809
  /**
3566
- * Time Complexity: O(n) - same as shift().
3567
- * Space Complexity: O(1) - same as shift().
3810
+ * Time Complexity: O(1)
3811
+ * Space Complexity: O(1)
3568
3812
  *
3569
3813
  * The `dequeue` function removes and returns the first element from a queue, or returns undefined if the queue is empty.
3570
3814
  * @returns The method is returning a value of type E or undefined.
@@ -3573,12 +3817,12 @@ var dataStructureTyped = (() => {
3573
3817
  return this.shift();
3574
3818
  }
3575
3819
  /**
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.
3820
+ * Time Complexity: O(1)
3821
+ * Space Complexity: O(1)
3578
3822
  */
3579
3823
  /**
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.
3824
+ * Time Complexity: O(1)
3825
+ * Space Complexity: O(1)
3582
3826
  *
3583
3827
  * @param index
3584
3828
  */
@@ -3586,12 +3830,12 @@ var dataStructureTyped = (() => {
3586
3830
  return this.elements[index];
3587
3831
  }
3588
3832
  /**
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.
3833
+ * Time Complexity: O(1)
3834
+ * Space Complexity: O(1)
3591
3835
  */
3592
3836
  /**
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.
3837
+ * Time Complexity: O(1)
3838
+ * Space Complexity: O(1)
3595
3839
  *
3596
3840
  * The function checks if a data structure is empty by comparing its size to zero.
3597
3841
  * @returns {boolean} A boolean value indicating whether the size of the object is 0 or not.
@@ -3600,12 +3844,12 @@ var dataStructureTyped = (() => {
3600
3844
  return this.size === 0;
3601
3845
  }
3602
3846
  /**
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.
3847
+ * Time Complexity: O(1)
3848
+ * Space Complexity: O(n)
3605
3849
  */
3606
3850
  /**
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.
3851
+ * Time Complexity: O(1)
3852
+ * Space Complexity: O(n)
3609
3853
  *
3610
3854
  * The toArray() function returns an array of elements from the current offset to the end of the _elements array.
3611
3855
  * @returns An array of type E is being returned.
@@ -3614,6 +3858,13 @@ var dataStructureTyped = (() => {
3614
3858
  return this.elements.slice(this.offset);
3615
3859
  }
3616
3860
  /**
3861
+ * Time Complexity: O(1)
3862
+ * Space Complexity: O(1)
3863
+ */
3864
+ /**
3865
+ * Time Complexity: O(1)
3866
+ * Space Complexity: O(1)
3867
+ *
3617
3868
  * The clear function resets the elements array and offset to their initial values.
3618
3869
  */
3619
3870
  clear() {
@@ -3697,6 +3948,12 @@ var dataStructureTyped = (() => {
3697
3948
  * Time Complexity: O(n)
3698
3949
  * Space Complexity: O(n)
3699
3950
  */
3951
+ /**
3952
+ * Time Complexity: O(n)
3953
+ * Space Complexity: O(n)
3954
+ *
3955
+ * The function `_getIterator` returns an iterable iterator for the elements in the class.
3956
+ */
3700
3957
  *_getIterator() {
3701
3958
  for (const item of this.elements) {
3702
3959
  yield item;
@@ -3765,12 +4022,12 @@ var dataStructureTyped = (() => {
3765
4022
  */
3766
4023
  constructor(elements = [], options) {
3767
4024
  super();
4025
+ __publicField(this, "_bucketSize", 1 << 12);
3768
4026
  __publicField(this, "_bucketFirst", 0);
3769
4027
  __publicField(this, "_firstInBucket", 0);
3770
4028
  __publicField(this, "_bucketLast", 0);
3771
4029
  __publicField(this, "_lastInBucket", 0);
3772
4030
  __publicField(this, "_bucketCount", 0);
3773
- __publicField(this, "_bucketSize", 1 << 12);
3774
4031
  __publicField(this, "_buckets", []);
3775
4032
  __publicField(this, "_size", 0);
3776
4033
  if (options) {
@@ -3809,9 +4066,45 @@ var dataStructureTyped = (() => {
3809
4066
  get bucketSize() {
3810
4067
  return this._bucketSize;
3811
4068
  }
4069
+ /**
4070
+ * The function returns the value of the protected variable `_bucketFirst`.
4071
+ * @returns The value of the `_bucketFirst` property.
4072
+ */
4073
+ get bucketFirst() {
4074
+ return this._bucketFirst;
4075
+ }
4076
+ /**
4077
+ * The function returns the value of the protected variable _firstInBucket.
4078
+ * @returns The method is returning the value of the variable `_firstInBucket`, which is of type
4079
+ * `number`.
4080
+ */
4081
+ get firstInBucket() {
4082
+ return this._firstInBucket;
4083
+ }
4084
+ /**
4085
+ * The function returns the value of the protected variable `_bucketLast`.
4086
+ * @returns The value of the `_bucketLast` property, which is a number.
4087
+ */
4088
+ get bucketLast() {
4089
+ return this._bucketLast;
4090
+ }
4091
+ /**
4092
+ * The function returns the value of the protected variable _lastInBucket.
4093
+ * @returns The method is returning the value of the variable `_lastInBucket`, which is of type
4094
+ * `number`.
4095
+ */
4096
+ get lastInBucket() {
4097
+ return this._lastInBucket;
4098
+ }
4099
+ /**
4100
+ * The function returns the number of buckets.
4101
+ * @returns The number of buckets.
4102
+ */
4103
+ get bucketCount() {
4104
+ return this._bucketCount;
4105
+ }
3812
4106
  /**
3813
4107
  * The buckets function returns the buckets property of the object.
3814
- *
3815
4108
  * @return The buckets property
3816
4109
  */
3817
4110
  get buckets() {
@@ -3968,13 +4261,27 @@ var dataStructureTyped = (() => {
3968
4261
  return element;
3969
4262
  }
3970
4263
  /**
3971
- * Time Complexity: O(1) - Removes the last element.
3972
- * Space Complexity: O(1) - Operates in-place.
4264
+ * Time Complexity: O(1)
4265
+ * Space Complexity: O(1)
4266
+ */
4267
+ /**
4268
+ * Time Complexity: O(1)
4269
+ * Space Complexity: O(1)
4270
+ *
4271
+ * The function checks if the size of an object is equal to zero and returns a boolean value.
4272
+ * @returns A boolean value indicating whether the size of the object is 0 or not.
3973
4273
  */
3974
4274
  isEmpty() {
3975
4275
  return this.size === 0;
3976
4276
  }
3977
4277
  /**
4278
+ * Time Complexity: O(1)
4279
+ * Space Complexity: O(1)
4280
+ */
4281
+ /**
4282
+ * Time Complexity: O(1)
4283
+ * Space Complexity: O(1)
4284
+ *
3978
4285
  * The clear() function resets the state of the object by initializing all variables to their default
3979
4286
  * values.
3980
4287
  */
@@ -4119,6 +4426,25 @@ var dataStructureTyped = (() => {
4119
4426
  return newDeque;
4120
4427
  }
4121
4428
  }
4429
+ /**
4430
+ * Time Complexity: O(1)
4431
+ * Space Complexity: O(1) or O(n)
4432
+ */
4433
+ /**
4434
+ * Time Complexity: O(1)
4435
+ * Space Complexity: O(1) or O(n)
4436
+ *
4437
+ * The `cutRest` function cuts the elements from a specified position in a deque and returns a new
4438
+ * deque with the cut elements.
4439
+ * @param {number} pos - The `pos` parameter represents the position from which to cut the Deque. It
4440
+ * is a number that indicates the index of the element in the Deque where the cut should start.
4441
+ * @param [isCutSelf=false] - isCutSelf is a boolean parameter that determines whether the original
4442
+ * Deque should be modified or a new Deque should be created. If isCutSelf is true, the original
4443
+ * Deque will be modified by cutting off elements starting from the specified position. If isCutSelf
4444
+ * is false, a new De
4445
+ * @returns The function `cutRest` returns either the modified original deque (`this`) or a new deque
4446
+ * (`newDeque`) depending on the value of the `isCutSelf` parameter.
4447
+ */
4122
4448
  cutRest(pos, isCutSelf = false) {
4123
4449
  if (isCutSelf) {
4124
4450
  if (pos < 0) {
@@ -4140,11 +4466,11 @@ var dataStructureTyped = (() => {
4140
4466
  }
4141
4467
  /**
4142
4468
  * Time Complexity: O(n)
4143
- * Space Complexity: O(1)
4469
+ * Space Complexity: O(1) or O(n)
4144
4470
  */
4145
4471
  /**
4146
4472
  * Time Complexity: O(n)
4147
- * Space Complexity: O(1)
4473
+ * Space Complexity: O(1) or O(n)
4148
4474
  *
4149
4475
  * The `deleteAt` function removes an element at a specified position in an array-like data
4150
4476
  * structure.
@@ -4430,8 +4756,8 @@ var dataStructureTyped = (() => {
4430
4756
  * Space Complexity: O(n) - Due to potential resizing.
4431
4757
  */
4432
4758
  /**
4433
- * Time Complexity: O(1)
4434
- * Space Complexity: O(n) - In worst case, resizing doubles the array size.
4759
+ * Time Complexity: Amortized O(1) - Similar to push, resizing leads to O(n).
4760
+ * Space Complexity: O(n) - Due to potential resizing.
4435
4761
  *
4436
4762
  * The addLast function adds an element to the end of an array.
4437
4763
  * @param {E} element - The element parameter represents the element that you want to add to the end of the
@@ -4441,12 +4767,12 @@ var dataStructureTyped = (() => {
4441
4767
  return this.push(element);
4442
4768
  }
4443
4769
  /**
4444
- * Time Complexity: O(1) - Removes the first element.
4445
- * Space Complexity: O(1) - In-place operation.
4770
+ * Time Complexity: O(1)
4771
+ * Space Complexity: O(1)
4446
4772
  */
4447
4773
  /**
4448
- * Time Complexity: O(1) - Removes the last element.
4449
- * Space Complexity: O(1) - Operates in-place.
4774
+ * Time Complexity: O(1)
4775
+ * Space Complexity: O(1)
4450
4776
  *
4451
4777
  * The function "pollLast" removes and returns the last element of an array.
4452
4778
  * @returns The last element of the array is being returned.
@@ -4455,34 +4781,49 @@ var dataStructureTyped = (() => {
4455
4781
  return this.pop();
4456
4782
  }
4457
4783
  /**
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
- */
4784
+ * Time Complexity: O(1)
4785
+ * Space Complexity: O(1)
4786
+ * /
4787
+
4788
+ /**
4789
+ * Time Complexity: O(1)
4790
+ * Space Complexity: O(1)
4791
+ *
4792
+ * The "addFirst" function adds an element to the beginning of an array.
4793
+ * @param {E} element - The parameter "element" represents the element that you want to add to the
4794
+ * beginning of the data structure.
4795
+ */
4465
4796
  addFirst(element) {
4466
4797
  return this.unshift(element);
4467
4798
  }
4468
4799
  /**
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
- */
4800
+ * Time Complexity: O(1)
4801
+ * Space Complexity: O(1)
4802
+ * /
4803
+
4804
+ /**
4805
+ * Time Complexity: O(1)
4806
+ * Space Complexity: O(1)
4807
+ *
4808
+ * The function "pollFirst" removes and returns the first element of an array.
4809
+ * @returns The method `pollFirst()` is returning the first element of the array after removing it
4810
+ * from the beginning. If the array is empty, it will return `undefined`.
4811
+ */
4476
4812
  pollFirst() {
4477
4813
  return this.shift();
4478
4814
  }
4479
4815
  /**
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
- */
4816
+ * Time Complexity: O(n)
4817
+ * Space Complexity: O(1)
4818
+ * /
4819
+
4820
+ /**
4821
+ * Time Complexity: O(n)
4822
+ * Space Complexity: O(1)
4823
+ *
4824
+ * The above function is an implementation of the iterator protocol in TypeScript, allowing the
4825
+ * object to be iterated over using a for...of loop.
4826
+ */
4486
4827
  *_getIterator() {
4487
4828
  for (let i = 0; i < this.size; ++i) {
4488
4829
  yield this.at(i);
@@ -4660,6 +5001,10 @@ var dataStructureTyped = (() => {
4660
5001
  }
4661
5002
  return value;
4662
5003
  }
5004
+ /**
5005
+ * Time Complexity: O(1)
5006
+ * Space Complexity: O(1)
5007
+ */
4663
5008
  /**
4664
5009
  * Time Complexity: O(1)
4665
5010
  * Space Complexity: O(1)
@@ -4684,11 +5029,11 @@ var dataStructureTyped = (() => {
4684
5029
  this._elements = [];
4685
5030
  }
4686
5031
  /**
4687
- * Time Complexity: O(n), where n is the number of elements in the elements array.
5032
+ * Time Complexity: O(n)
4688
5033
  * Space Complexity: O(n)
4689
5034
  */
4690
5035
  /**
4691
- * Time Complexity: O(n), where n is the number of elements in the elements array.
5036
+ * Time Complexity: O(n)
4692
5037
  * Space Complexity: O(n)
4693
5038
  *
4694
5039
  * Clear and add elements of the heap
@@ -4699,11 +5044,11 @@ var dataStructureTyped = (() => {
4699
5044
  return this.fix();
4700
5045
  }
4701
5046
  /**
4702
- * Time Complexity: O(n), where n is the number of elements in the heap.
5047
+ * Time Complexity: O(n)
4703
5048
  * Space Complexity: O(1)
4704
5049
  */
4705
5050
  /**
4706
- * Time Complexity: O(n), where n is the number of elements in the heap.
5051
+ * Time Complexity: O(n)
4707
5052
  * Space Complexity: O(1)
4708
5053
  *
4709
5054
  * Use a comparison function to check whether a binary heap contains a specific element.
@@ -4714,11 +5059,12 @@ var dataStructureTyped = (() => {
4714
5059
  return this.elements.includes(element);
4715
5060
  }
4716
5061
  /**
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.
5062
+ * Time Complexity: O(n)
4718
5063
  * Space Complexity: O(1)
5064
+ * 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
5065
  */
4720
5066
  /**
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.
5067
+ * Time Complexity: O(n)
4722
5068
  * Space Complexity: O(1)
4723
5069
  *
4724
5070
  * The `delete` function removes an element from an array-like data structure, maintaining the order
@@ -4744,12 +5090,13 @@ var dataStructureTyped = (() => {
4744
5090
  return true;
4745
5091
  }
4746
5092
  /**
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.
5093
+ * Time Complexity: O(n)
5094
+ * Space Complexity: O(log n)
5095
+ * where log n is the height of the heap.
4749
5096
  */
4750
5097
  /**
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.
5098
+ * Time Complexity: O(n)
5099
+ * Space Complexity: O(log n)
4753
5100
  *
4754
5101
  * Depth-first search (DFS) method, different traversal orders can be selected。
4755
5102
  * @param order - Traverse order parameter: 'in' (in-order), 'pre' (pre-order) or 'post' (post-order).
@@ -4830,12 +5177,12 @@ var dataStructureTyped = (() => {
4830
5177
  return visitedNode;
4831
5178
  }
4832
5179
  /**
4833
- * Time Complexity: O(log n)
4834
- * Space Complexity: O(1)
5180
+ * Time Complexity: O(n log n)
5181
+ * Space Complexity: O(n)
4835
5182
  */
4836
5183
  /**
4837
- * Time Complexity: O(n)
4838
- * Space Complexity: O(1)
5184
+ * Time Complexity: O(n log n)
5185
+ * Space Complexity: O(n)
4839
5186
  *
4840
5187
  * Fix the entire heap to maintain heap properties.
4841
5188
  */
@@ -4918,7 +5265,7 @@ var dataStructureTyped = (() => {
4918
5265
  }
4919
5266
  }
4920
5267
  /**
4921
- * Time Complexity: O(n)
5268
+ * Time Complexity: O(log n)
4922
5269
  * Space Complexity: O(1)
4923
5270
  */
4924
5271
  /**
@@ -4941,6 +5288,10 @@ var dataStructureTyped = (() => {
4941
5288
  this.elements[index] = element;
4942
5289
  return true;
4943
5290
  }
5291
+ /**
5292
+ * Time Complexity: O(log n)
5293
+ * Space Complexity: O(1)
5294
+ */
4944
5295
  /**
4945
5296
  * Time Complexity: O(log n)
4946
5297
  * Space Complexity: O(1)
@@ -5151,11 +5502,11 @@ var dataStructureTyped = (() => {
5151
5502
  }
5152
5503
  }
5153
5504
  /**
5154
- * Time Complexity: O(log n), where n is the number of elements in the heap.
5505
+ * Time Complexity: O(log n)
5155
5506
  * Space Complexity: O(1)
5156
5507
  */
5157
5508
  /**
5158
- * Time Complexity: O(log n), where n is the number of elements in the heap.
5509
+ * Time Complexity: O(log n)
5159
5510
  * Space Complexity: O(1)
5160
5511
  *
5161
5512
  * Remove and return the top element (smallest or largest element) from the heap.
@@ -5165,11 +5516,11 @@ var dataStructureTyped = (() => {
5165
5516
  return this.pop();
5166
5517
  }
5167
5518
  /**
5168
- * Time Complexity: O(log n), where n is the number of elements in the heap.
5519
+ * Time Complexity: O(log n)
5169
5520
  * Space Complexity: O(1)
5170
5521
  */
5171
5522
  /**
5172
- * Time Complexity: O(log n), where n is the number of elements in the heap.
5523
+ * Time Complexity: O(log n)
5173
5524
  * Space Complexity: O(1)
5174
5525
  *
5175
5526
  * Remove and return the top element (smallest or largest element) from the heap.
@@ -6184,188 +6535,6 @@ var dataStructureTyped = (() => {
6184
6535
  }
6185
6536
  return { costs, predecessor };
6186
6537
  }
6187
- /**
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
- }
6275
- }
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
6538
  /**
6370
6539
  * O(V+E+C)
6371
6540
  * O(V+C)
@@ -7011,6 +7180,21 @@ var dataStructureTyped = (() => {
7011
7180
  isEmpty() {
7012
7181
  return this.vertexMap.size === 0 && this.inEdgeMap.size === 0 && this.outEdgeMap.size === 0;
7013
7182
  }
7183
+ /**
7184
+ * Time Complexity: O(1)
7185
+ * Space Complexity: O(1)
7186
+ */
7187
+ /**
7188
+ * Time Complexity: O(1)
7189
+ * Space Complexity: O(1)
7190
+ *
7191
+ * The clear function resets the vertex map, in-edge map, and out-edge map.
7192
+ */
7193
+ clear() {
7194
+ this._vertexMap = /* @__PURE__ */ new Map();
7195
+ this._inEdgeMap = /* @__PURE__ */ new Map();
7196
+ this._outEdgeMap = /* @__PURE__ */ new Map();
7197
+ }
7014
7198
  /**
7015
7199
  * The clone function creates a new DirectedGraph object with the same vertices and edges as the original.
7016
7200
  *
@@ -7023,6 +7207,95 @@ var dataStructureTyped = (() => {
7023
7207
  cloned.outEdgeMap = new Map(this.outEdgeMap);
7024
7208
  return cloned;
7025
7209
  }
7210
+ /**
7211
+ * Time Complexity: O(V + E)
7212
+ * Space Complexity: O(V)
7213
+ * Tarjan is an algorithm based on dfs,which is used to solve the connectivity problem of graphs.
7214
+ * Tarjan can find the SSC(strongly connected components), articulation points, and bridges of directed graphs.
7215
+ */
7216
+ /**
7217
+ * Time Complexity: O(V + E)
7218
+ * Space Complexity: O(V)
7219
+ * Tarjan is an algorithm based on dfs,which is used to solve the connectivity problem of graphs.
7220
+ * Tarjan can find the SSC(strongly connected components), articulation points, and bridges of directed graphs.
7221
+ *
7222
+ * The function `tarjan` implements the Tarjan's algorithm to find strongly connected components in a
7223
+ * graph.
7224
+ * @returns The function `tarjan()` returns an object with three properties: `dfnMap`, `lowMap`, and
7225
+ * `SCCs`.
7226
+ */
7227
+ tarjan() {
7228
+ const dfnMap = /* @__PURE__ */ new Map();
7229
+ const lowMap = /* @__PURE__ */ new Map();
7230
+ const SCCs = /* @__PURE__ */ new Map();
7231
+ let time = 0;
7232
+ const stack = [];
7233
+ const inStack = /* @__PURE__ */ new Set();
7234
+ const dfs = (vertex) => {
7235
+ dfnMap.set(vertex, time);
7236
+ lowMap.set(vertex, time);
7237
+ time++;
7238
+ stack.push(vertex);
7239
+ inStack.add(vertex);
7240
+ const neighbors = this.getNeighbors(vertex);
7241
+ for (const neighbor of neighbors) {
7242
+ if (!dfnMap.has(neighbor)) {
7243
+ dfs(neighbor);
7244
+ lowMap.set(vertex, Math.min(lowMap.get(vertex), lowMap.get(neighbor)));
7245
+ } else if (inStack.has(neighbor)) {
7246
+ lowMap.set(vertex, Math.min(lowMap.get(vertex), dfnMap.get(neighbor)));
7247
+ }
7248
+ }
7249
+ if (dfnMap.get(vertex) === lowMap.get(vertex)) {
7250
+ const SCC = [];
7251
+ let poppedVertex;
7252
+ do {
7253
+ poppedVertex = stack.pop();
7254
+ inStack.delete(poppedVertex);
7255
+ SCC.push(poppedVertex);
7256
+ } while (poppedVertex !== vertex);
7257
+ SCCs.set(SCCs.size, SCC);
7258
+ }
7259
+ };
7260
+ for (const vertex of this.vertexMap.values()) {
7261
+ if (!dfnMap.has(vertex)) {
7262
+ dfs(vertex);
7263
+ }
7264
+ }
7265
+ return { dfnMap, lowMap, SCCs };
7266
+ }
7267
+ /**
7268
+ * Time Complexity: O(V + E) - Depends on the implementation (Tarjan's algorithm).
7269
+ * Space Complexity: O(V) - Depends on the implementation (Tarjan's algorithm).
7270
+ */
7271
+ /**
7272
+ * Time Complexity: O(V + E) - Depends on the implementation (Tarjan's algorithm).
7273
+ * Space Complexity: O(V) - Depends on the implementation (Tarjan's algorithm).
7274
+ *
7275
+ * The function returns a map that associates each vertex object with its corresponding depth-first
7276
+ * number.
7277
+ * @returns A Map object with keys of type VO and values of type number.
7278
+ */
7279
+ getDFNMap() {
7280
+ return this.tarjan().dfnMap;
7281
+ }
7282
+ /**
7283
+ * The function returns a Map object that contains the low values of each vertex in a Tarjan
7284
+ * algorithm.
7285
+ * @returns The method `getLowMap()` is returning a `Map` object with keys of type `VO` and values of
7286
+ * type `number`.
7287
+ */
7288
+ getLowMap() {
7289
+ return this.tarjan().lowMap;
7290
+ }
7291
+ /**
7292
+ * The function "getSCCs" returns a map of strongly connected components (SCCs) using the Tarjan
7293
+ * algorithm.
7294
+ * @returns a map where the keys are numbers and the values are arrays of VO objects.
7295
+ */
7296
+ getSCCs() {
7297
+ return this.tarjan().SCCs;
7298
+ }
7026
7299
  /**
7027
7300
  * Time Complexity: O(1)
7028
7301
  * Space Complexity: O(1)
@@ -7089,8 +7362,8 @@ var dataStructureTyped = (() => {
7089
7362
  */
7090
7363
  constructor(v1, v2, weight, value) {
7091
7364
  super(weight, value);
7092
- __publicField(this, "vertexMap");
7093
- this.vertexMap = [v1, v2];
7365
+ __publicField(this, "endpoints");
7366
+ this.endpoints = [v1, v2];
7094
7367
  }
7095
7368
  };
7096
7369
  var UndirectedGraph = class _UndirectedGraph extends AbstractGraph {
@@ -7141,7 +7414,7 @@ var dataStructureTyped = (() => {
7141
7414
  * Time Complexity: O(|E|), where |E| is the number of edgeMap incident to the given vertex.
7142
7415
  * Space Complexity: O(1)
7143
7416
  *
7144
- * The function `getEdge` returns the first edge that connects two vertexMap, or undefined if no such edge exists.
7417
+ * The function `getEdge` returns the first edge that connects two endpoints, or undefined if no such edge exists.
7145
7418
  * @param {VO | VertexKey | undefined} v1 - The parameter `v1` represents a vertex or vertex ID. It can be of type `VO` (vertex
7146
7419
  * object), `undefined`, or `VertexKey` (a string or number representing the ID of a vertex).
7147
7420
  * @param {VO | VertexKey | undefined} v2 - The parameter `v2` represents a vertex or vertex ID. It can be of type `VO` (vertex
@@ -7155,7 +7428,7 @@ var dataStructureTyped = (() => {
7155
7428
  const vertex1 = this._getVertex(v1);
7156
7429
  const vertex2 = this._getVertex(v2);
7157
7430
  if (vertex1 && vertex2) {
7158
- edgeMap = (_a = this._edgeMap.get(vertex1)) == null ? void 0 : _a.filter((e) => e.vertexMap.includes(vertex2.key));
7431
+ edgeMap = (_a = this._edgeMap.get(vertex1)) == null ? void 0 : _a.filter((e) => e.endpoints.includes(vertex2.key));
7159
7432
  }
7160
7433
  }
7161
7434
  return edgeMap ? edgeMap[0] || void 0 : void 0;
@@ -7172,7 +7445,7 @@ var dataStructureTyped = (() => {
7172
7445
  * @param {VO | VertexKey} v1 - The parameter `v1` represents either a vertex object (`VO`) or a vertex ID (`VertexKey`).
7173
7446
  * @param {VO | VertexKey} v2 - VO | VertexKey - This parameter can be either a vertex object (VO) or a vertex ID
7174
7447
  * (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.
7448
+ * @returns the removed edge (EO) if it exists, or undefined if either of the endpoints (VO) does not exist.
7176
7449
  */
7177
7450
  deleteEdgeBetween(v1, v2) {
7178
7451
  const vertex1 = this._getVertex(v1);
@@ -7183,11 +7456,11 @@ var dataStructureTyped = (() => {
7183
7456
  const v1Edges = this._edgeMap.get(vertex1);
7184
7457
  let removed = void 0;
7185
7458
  if (v1Edges) {
7186
- removed = arrayRemove(v1Edges, (e) => e.vertexMap.includes(vertex2.key))[0] || void 0;
7459
+ removed = arrayRemove(v1Edges, (e) => e.endpoints.includes(vertex2.key))[0] || void 0;
7187
7460
  }
7188
7461
  const v2Edges = this._edgeMap.get(vertex2);
7189
7462
  if (v2Edges) {
7190
- arrayRemove(v2Edges, (e) => e.vertexMap.includes(vertex1.key));
7463
+ arrayRemove(v2Edges, (e) => e.endpoints.includes(vertex1.key));
7191
7464
  }
7192
7465
  return removed;
7193
7466
  }
@@ -7199,7 +7472,7 @@ var dataStructureTyped = (() => {
7199
7472
  * Time Complexity: O(E), where E is the number of edgeMap incident to the given vertex.
7200
7473
  * Space Complexity: O(1)
7201
7474
  *
7202
- * The function `deleteEdge` deletes an edge between two vertexMap in a graph.
7475
+ * The function `deleteEdge` deletes an edge between two endpoints in a graph.
7203
7476
  * @param {EO | VertexKey} edgeOrOneSideVertexKey - The parameter `edgeOrOneSideVertexKey` can be
7204
7477
  * either an edge object or a vertex key.
7205
7478
  * @param {VertexKey} [otherSideVertexKey] - The parameter `otherSideVertexKey` is an optional
@@ -7218,8 +7491,8 @@ var dataStructureTyped = (() => {
7218
7491
  return;
7219
7492
  }
7220
7493
  } else {
7221
- oneSide = this._getVertex(edgeOrOneSideVertexKey.vertexMap[0]);
7222
- otherSide = this._getVertex(edgeOrOneSideVertexKey.vertexMap[1]);
7494
+ oneSide = this._getVertex(edgeOrOneSideVertexKey.endpoints[0]);
7495
+ otherSide = this._getVertex(edgeOrOneSideVertexKey.endpoints[1]);
7223
7496
  }
7224
7497
  if (oneSide && otherSide) {
7225
7498
  return this.deleteEdgeBetween(oneSide, otherSide);
@@ -7256,7 +7529,7 @@ var dataStructureTyped = (() => {
7256
7529
  const neighborEdges = this._edgeMap.get(neighbor);
7257
7530
  if (neighborEdges) {
7258
7531
  const restEdges = neighborEdges.filter((edge) => {
7259
- return !edge.vertexMap.includes(vertexKey);
7532
+ return !edge.endpoints.includes(vertexKey);
7260
7533
  });
7261
7534
  this._edgeMap.set(neighbor, restEdges);
7262
7535
  }
@@ -7337,7 +7610,7 @@ var dataStructureTyped = (() => {
7337
7610
  * Time Complexity: O(|V| + |E|), where |V| is the number of vertexMap and |E| is the number of edgeMap.
7338
7611
  * Space Complexity: O(|E|)
7339
7612
  *
7340
- * The function "getNeighbors" returns an array of neighboring vertexMap for a given vertex or vertex ID.
7613
+ * The function "getNeighbors" returns an array of neighboring endpoints for a given vertex or vertex ID.
7341
7614
  * @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`VO`) or a vertex ID
7342
7615
  * (`VertexKey`).
7343
7616
  * @returns an array of vertexMap (VO[]).
@@ -7348,7 +7621,7 @@ var dataStructureTyped = (() => {
7348
7621
  if (vertex) {
7349
7622
  const neighborEdges = this.edgesOf(vertex);
7350
7623
  for (const edge of neighborEdges) {
7351
- const neighbor = this._getVertex(edge.vertexMap.filter((e) => e !== vertex.key)[0]);
7624
+ const neighbor = this._getVertex(edge.endpoints.filter((e) => e !== vertex.key)[0]);
7352
7625
  if (neighbor) {
7353
7626
  neighbors.push(neighbor);
7354
7627
  }
@@ -7364,18 +7637,18 @@ var dataStructureTyped = (() => {
7364
7637
  * Time Complexity: O(1)
7365
7638
  * Space Complexity: O(1)
7366
7639
  *
7367
- * The function "getEndsOfEdge" returns the vertexMap at the ends of an edge if the edge exists in the graph, otherwise
7640
+ * The function "getEndsOfEdge" returns the endpoints at the ends of an edge if the edge exists in the graph, otherwise
7368
7641
  * it returns undefined.
7369
7642
  * @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
7643
+ * @returns The function `getEndsOfEdge` returns an array containing two endpoints `[VO, VO]` if the edge exists in the
7371
7644
  * graph. If the edge does not exist, it returns `undefined`.
7372
7645
  */
7373
7646
  getEndsOfEdge(edge) {
7374
- if (!this.hasEdge(edge.vertexMap[0], edge.vertexMap[1])) {
7647
+ if (!this.hasEdge(edge.endpoints[0], edge.endpoints[1])) {
7375
7648
  return void 0;
7376
7649
  }
7377
- const v1 = this._getVertex(edge.vertexMap[0]);
7378
- const v2 = this._getVertex(edge.vertexMap[1]);
7650
+ const v1 = this._getVertex(edge.endpoints[0]);
7651
+ const v2 = this._getVertex(edge.endpoints[1]);
7379
7652
  if (v1 && v2) {
7380
7653
  return [v1, v2];
7381
7654
  } else {
@@ -7389,6 +7662,20 @@ var dataStructureTyped = (() => {
7389
7662
  isEmpty() {
7390
7663
  return this.vertexMap.size === 0 && this.edgeMap.size === 0;
7391
7664
  }
7665
+ /**
7666
+ * Time Complexity: O(1)
7667
+ * Space Complexity: O(1)
7668
+ */
7669
+ /**
7670
+ * Time Complexity: O(1)
7671
+ * Space Complexity: O(1)
7672
+ *
7673
+ * The clear function resets the vertex and edge maps to empty maps.
7674
+ */
7675
+ clear() {
7676
+ this._vertexMap = /* @__PURE__ */ new Map();
7677
+ this._edgeMap = /* @__PURE__ */ new Map();
7678
+ }
7392
7679
  /**
7393
7680
  * The clone function creates a new UndirectedGraph object and copies the
7394
7681
  * vertexMap and edgeMap from this graph to the new one. This is done by
@@ -7398,16 +7685,106 @@ var dataStructureTyped = (() => {
7398
7685
  *
7399
7686
  * @return A new instance of the undirectedgraph class
7400
7687
  */
7401
- clone() {
7402
- const cloned = new _UndirectedGraph();
7403
- cloned.vertexMap = new Map(this.vertexMap);
7404
- cloned.edgeMap = new Map(this.edgeMap);
7405
- return cloned;
7688
+ clone() {
7689
+ const cloned = new _UndirectedGraph();
7690
+ cloned.vertexMap = new Map(this.vertexMap);
7691
+ cloned.edgeMap = new Map(this.edgeMap);
7692
+ return cloned;
7693
+ }
7694
+ /**
7695
+ * Time Complexity: O(1)
7696
+ * Space Complexity: O(1)
7697
+ */
7698
+ /**
7699
+ * Time Complexity: O(V + E)
7700
+ * Space Complexity: O(V)
7701
+ * Tarjan is an algorithm based on dfs,which is used to solve the connectivity problem of graphs.
7702
+ * 1. Tarjan can find the articulation points and bridges(critical edgeMap) of undirected graphs in linear time
7703
+ *
7704
+ * The function `tarjan` implements the Tarjan's algorithm to find bridges and cut vertices in a
7705
+ * graph.
7706
+ * @returns The function `tarjan()` returns an object with the following properties:
7707
+ */
7708
+ tarjan() {
7709
+ const dfnMap = /* @__PURE__ */ new Map();
7710
+ const lowMap = /* @__PURE__ */ new Map();
7711
+ const bridges = [];
7712
+ const cutVertices = [];
7713
+ let time = 0;
7714
+ const dfs = (vertex, parent) => {
7715
+ dfnMap.set(vertex, time);
7716
+ lowMap.set(vertex, time);
7717
+ time++;
7718
+ const neighbors = this.getNeighbors(vertex);
7719
+ let childCount = 0;
7720
+ for (const neighbor of neighbors) {
7721
+ if (!dfnMap.has(neighbor)) {
7722
+ childCount++;
7723
+ dfs(neighbor, vertex);
7724
+ lowMap.set(vertex, Math.min(lowMap.get(vertex), lowMap.get(neighbor)));
7725
+ if (lowMap.get(neighbor) > dfnMap.get(vertex)) {
7726
+ const edge = this.getEdge(vertex, neighbor);
7727
+ if (edge) {
7728
+ bridges.push(edge);
7729
+ }
7730
+ }
7731
+ if (parent !== void 0 && lowMap.get(neighbor) >= dfnMap.get(vertex)) {
7732
+ cutVertices.push(vertex);
7733
+ }
7734
+ } else if (neighbor !== parent) {
7735
+ lowMap.set(vertex, Math.min(lowMap.get(vertex), dfnMap.get(neighbor)));
7736
+ }
7737
+ }
7738
+ if (parent === void 0 && childCount > 1) {
7739
+ cutVertices.push(vertex);
7740
+ }
7741
+ };
7742
+ for (const vertex of this.vertexMap.values()) {
7743
+ if (!dfnMap.has(vertex)) {
7744
+ dfs(vertex, void 0);
7745
+ }
7746
+ }
7747
+ return {
7748
+ dfnMap,
7749
+ lowMap,
7750
+ bridges,
7751
+ cutVertices
7752
+ };
7753
+ }
7754
+ /**
7755
+ * Time Complexity: O(V + E)
7756
+ * Space Complexity: O(V)
7757
+ * Tarjan is an algorithm based on dfs,which is used to solve the connectivity problem of graphs.
7758
+ * 1. Tarjan can find the articulation points and bridges(critical edgeMap) of undirected graphs in linear time
7759
+ */
7760
+ /**
7761
+ * The function "getBridges" returns an array of bridges in a graph using the Tarjan's algorithm.
7762
+ * @returns The function `getBridges()` is returning the bridges found using the Tarjan's algorithm.
7763
+ */
7764
+ getBridges() {
7765
+ return this.tarjan().bridges;
7766
+ }
7767
+ /**
7768
+ * The function "getCutVertices" returns an array of cut vertices using the Tarjan's algorithm.
7769
+ * @returns the cut vertices found using the Tarjan's algorithm.
7770
+ */
7771
+ getCutVertices() {
7772
+ return this.tarjan().cutVertices;
7406
7773
  }
7407
7774
  /**
7408
- * Time Complexity: O(1)
7409
- * Space Complexity: O(1)
7775
+ * The function returns the dfnMap property of the result of the tarjan() function.
7776
+ * @returns the `dfnMap` property of the result of calling the `tarjan()` function.
7777
+ */
7778
+ getDFNMap() {
7779
+ return this.tarjan().dfnMap;
7780
+ }
7781
+ /**
7782
+ * The function returns the lowMap property of the result of the tarjan() function.
7783
+ * @returns the lowMap property of the result of calling the tarjan() function.
7410
7784
  */
7785
+ getLowMap() {
7786
+ return this.tarjan().lowMap;
7787
+ }
7411
7788
  /**
7412
7789
  * Time Complexity: O(1)
7413
7790
  * Space Complexity: O(1)
@@ -7417,7 +7794,7 @@ var dataStructureTyped = (() => {
7417
7794
  * @returns a boolean value.
7418
7795
  */
7419
7796
  _addEdge(edge) {
7420
- for (const end of edge.vertexMap) {
7797
+ for (const end of edge.endpoints) {
7421
7798
  const endVertex = this._getVertex(end);
7422
7799
  if (endVertex === void 0)
7423
7800
  return false;
@@ -7579,7 +7956,7 @@ var dataStructureTyped = (() => {
7579
7956
  /**
7580
7957
  * The constructor function initializes an object with a key and an optional value.
7581
7958
  * @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.
7959
+ * constructor. It is used to set the key property of the object being created.
7583
7960
  * @param {V} [value] - The "value" parameter is an optional parameter of type V. It represents the
7584
7961
  * value associated with the key in the constructor.
7585
7962
  */
@@ -9263,18 +9640,37 @@ var dataStructureTyped = (() => {
9263
9640
  this._left = void 0;
9264
9641
  this._right = void 0;
9265
9642
  }
9643
+ /**
9644
+ * The function returns the value of the `_left` property.
9645
+ * @returns The `_left` property of the current object is being returned.
9646
+ */
9266
9647
  get left() {
9267
9648
  return this._left;
9268
9649
  }
9650
+ /**
9651
+ * The function sets the left child of a node and updates the parent reference of the child.
9652
+ * @param {NODE | undefined} v - The parameter `v` is of type `NODE | undefined`. It can either be an
9653
+ * instance of the `NODE` class or `undefined`.
9654
+ */
9269
9655
  set left(v) {
9270
9656
  if (v) {
9271
9657
  v.parent = this;
9272
9658
  }
9273
9659
  this._left = v;
9274
9660
  }
9661
+ /**
9662
+ * The function returns the right node of a binary tree or undefined if there is no right node.
9663
+ * @returns The method is returning the value of the `_right` property, which is of type `NODE` or
9664
+ * `undefined`.
9665
+ */
9275
9666
  get right() {
9276
9667
  return this._right;
9277
9668
  }
9669
+ /**
9670
+ * The function sets the right child of a node and updates the parent reference of the child.
9671
+ * @param {NODE | undefined} v - The parameter `v` is of type `NODE | undefined`. It can either be a
9672
+ * `NODE` object or `undefined`.
9673
+ */
9278
9674
  set right(v) {
9279
9675
  if (v) {
9280
9676
  v.parent = this;
@@ -9284,10 +9680,10 @@ var dataStructureTyped = (() => {
9284
9680
  };
9285
9681
  var BST = class _BST extends BinaryTree {
9286
9682
  /**
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.
9683
+ * This is the constructor function for a TypeScript class that initializes a binary search tree with
9684
+ * optional keys or nodes or entries and options.
9685
+ * @param keysOrNodesOrEntries - An iterable object that contains keys, nodes, or entries. It is used
9686
+ * to initialize the binary search tree with the provided keys, nodes, or entries.
9291
9687
  * @param [options] - The `options` parameter is an optional object that can contain additional
9292
9688
  * configuration options for the binary search tree. It can have the following properties:
9293
9689
  */
@@ -9304,19 +9700,27 @@ var dataStructureTyped = (() => {
9304
9700
  if (keysOrNodesOrEntries)
9305
9701
  this.addMany(keysOrNodesOrEntries);
9306
9702
  }
9703
+ /**
9704
+ * The function returns the root node of a tree structure.
9705
+ * @returns The `_root` property of the object, which is of type `NODE` or `undefined`.
9706
+ */
9307
9707
  get root() {
9308
9708
  return this._root;
9309
9709
  }
9710
+ /**
9711
+ * The function returns the value of the _variant property.
9712
+ * @returns The value of the `_variant` property.
9713
+ */
9310
9714
  get variant() {
9311
9715
  return this._variant;
9312
9716
  }
9313
9717
  /**
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.
9718
+ * The function creates a new BSTNode with the given key and value and returns it.
9719
+ * @param {K} key - The key parameter is of type K, which represents the type of the key for the node
9720
+ * being created.
9721
+ * @param {V} [value] - The "value" parameter is an optional parameter of type V. It represents the
9722
+ * value associated with the key in the node being created.
9723
+ * @returns The method is returning a new instance of the BSTNode class, casted as the NODE type.
9320
9724
  */
9321
9725
  createNode(key, value) {
9322
9726
  return new BSTNode(key, value);
@@ -9324,9 +9728,10 @@ var dataStructureTyped = (() => {
9324
9728
  /**
9325
9729
  * The function creates a new binary search tree with the specified options.
9326
9730
  * @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.
9731
+ * behavior of the `createTree` method. It is of type `Partial<BSTOptions<K>>`, which means it is a
9732
+ * partial object of type `BSTOptions<K>`.
9733
+ * @returns a new instance of the BST class, with the provided options merged with the default
9734
+ * options. The returned value is casted as TREE.
9330
9735
  */
9331
9736
  createTree(options) {
9332
9737
  return new _BST([], __spreadValues({
@@ -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,17 +10675,118 @@ var dataStructureTyped = (() => {
10243
10675
 
10244
10676
  // src/data-structures/binary-tree/segment-tree.ts
10245
10677
  var SegmentTreeNode = class {
10678
+ /**
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.
10688
+ */
10246
10689
  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;
10690
+ __publicField(this, "_start", 0);
10691
+ __publicField(this, "_end", 0);
10692
+ __publicField(this, "_value");
10693
+ __publicField(this, "_sum", 0);
10694
+ __publicField(this, "_left");
10695
+ __publicField(this, "_right");
10696
+ this._start = start;
10697
+ this._end = end;
10698
+ this._sum = sum;
10699
+ this._value = value || void 0;
10700
+ }
10701
+ /**
10702
+ * The function returns the value of the protected variable _start.
10703
+ * @returns The start value, which is of type number.
10704
+ */
10705
+ get start() {
10706
+ return this._start;
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
+ */
10719
+ get end() {
10720
+ return this._end;
10721
+ }
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;
10729
+ }
10730
+ /**
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;
10257
10790
  }
10258
10791
  };
10259
10792
  var SegmentTree = class {
@@ -10283,15 +10816,31 @@ var dataStructureTyped = (() => {
10283
10816
  this._values = [];
10284
10817
  }
10285
10818
  }
10819
+ /**
10820
+ * The function returns an array of numbers.
10821
+ * @returns An array of numbers is being returned.
10822
+ */
10286
10823
  get values() {
10287
10824
  return this._values;
10288
10825
  }
10826
+ /**
10827
+ * The function returns the value of the protected variable _start.
10828
+ * @returns The start value, which is of type number.
10829
+ */
10289
10830
  get start() {
10290
10831
  return this._start;
10291
10832
  }
10833
+ /**
10834
+ * The function returns the value of the protected variable `_end`.
10835
+ * @returns The value of the protected property `_end`.
10836
+ */
10292
10837
  get end() {
10293
10838
  return this._end;
10294
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
+ */
10295
10844
  get root() {
10296
10845
  return this._root;
10297
10846
  }
@@ -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
  }
@@ -11371,9 +12010,24 @@ var dataStructureTyped = (() => {
11371
12010
  */
11372
12011
  constructor(key, value, count = 1) {
11373
12012
  super(key, value);
11374
- __publicField(this, "count");
12013
+ __publicField(this, "_count", 1);
11375
12014
  this.count = count;
11376
12015
  }
12016
+ /**
12017
+ * The function returns the value of the protected variable _count.
12018
+ * @returns The count property of the object, which is of type number.
12019
+ */
12020
+ get count() {
12021
+ return this._count;
12022
+ }
12023
+ /**
12024
+ * The above function sets the value of the count property.
12025
+ * @param {number} value - The value parameter is of type number, which means it can accept any
12026
+ * numeric value.
12027
+ */
12028
+ set count(value) {
12029
+ this._count = value;
12030
+ }
11377
12031
  };
11378
12032
  var TreeMultimap = class _TreeMultimap extends AVLTree {
11379
12033
  constructor(keysOrNodesOrEntries = [], options) {
@@ -11383,6 +12037,11 @@ var dataStructureTyped = (() => {
11383
12037
  this.addMany(keysOrNodesOrEntries);
11384
12038
  }
11385
12039
  // TODO the _count is not accurate after nodes count modified
12040
+ /**
12041
+ * The function calculates the sum of the count property of all nodes in a tree using depth-first
12042
+ * search.
12043
+ * @returns the sum of the count property of all nodes in the tree.
12044
+ */
11386
12045
  get count() {
11387
12046
  let sum = 0;
11388
12047
  this.dfs((node) => sum += node.count);
@@ -11400,6 +12059,15 @@ var dataStructureTyped = (() => {
11400
12059
  createNode(key, value, count) {
11401
12060
  return new TreeMultimapNode(key, value, count);
11402
12061
  }
12062
+ /**
12063
+ * The function creates a new TreeMultimap object with the specified options and returns it.
12064
+ * @param [options] - The `options` parameter is an optional object that contains additional
12065
+ * configuration options for creating the `TreeMultimap` object. It can include properties such as
12066
+ * `iterationType` and `variant`, which are used to specify the type of iteration and the variant of
12067
+ * the tree, respectively. These properties can be
12068
+ * @returns a new instance of the `TreeMultimap` class, with the provided options merged with the
12069
+ * default options. The returned value is casted as `TREE`.
12070
+ */
11403
12071
  createTree(options) {
11404
12072
  return new _TreeMultimap([], __spreadValues({
11405
12073
  iterationType: this.iterationType,
@@ -11662,6 +12330,14 @@ var dataStructureTyped = (() => {
11662
12330
  }
11663
12331
  return void 0;
11664
12332
  }
12333
+ /**
12334
+ * The function replaces an old node with a new node and updates the count property of the new node.
12335
+ * @param {NODE} oldNode - The `oldNode` parameter is of type `NODE` and represents the node that
12336
+ * needs to be replaced in a data structure.
12337
+ * @param {NODE} newNode - The `newNode` parameter is an object of type `NODE`.
12338
+ * @returns The method is returning the result of calling the `_replaceNode` method from the
12339
+ * superclass, after updating the `count` property of the `newNode` object.
12340
+ */
11665
12341
  _replaceNode(oldNode, newNode) {
11666
12342
  newNode.count = oldNode.count + newNode.count;
11667
12343
  return super._replaceNode(oldNode, newNode);
@@ -11670,24 +12346,90 @@ var dataStructureTyped = (() => {
11670
12346
 
11671
12347
  // src/data-structures/tree/tree.ts
11672
12348
  var TreeNode = class _TreeNode {
12349
+ /**
12350
+ * The constructor function initializes a TreeNode object with a key, optional value, and optional
12351
+ * children.
12352
+ * @param {string} key - A string representing the key of the tree node.
12353
+ * @param {V} [value] - The `value` parameter is an optional parameter of type `V`. It represents the
12354
+ * value associated with the node. If no value is provided, it defaults to `undefined`.
12355
+ * @param {TreeNode<V>[]} [children] - The `children` parameter is an optional array of `TreeNode<V>`
12356
+ * objects. It represents the child nodes of the current node. If no children are provided, the
12357
+ * default value is an empty array.
12358
+ */
11673
12359
  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 || [];
12360
+ __publicField(this, "_key");
12361
+ __publicField(this, "_value");
12362
+ __publicField(this, "_children");
12363
+ this._key = key;
12364
+ this._value = value || void 0;
12365
+ this._children = children || [];
12366
+ }
12367
+ /**
12368
+ * The function returns the value of the protected variable _key.
12369
+ * @returns The value of the `_key` property, which is a string.
12370
+ */
12371
+ get key() {
12372
+ return this._key;
12373
+ }
12374
+ /**
12375
+ * The above function sets the value of a protected variable called "key".
12376
+ * @param {string} value - The value parameter is a string that represents the value to be assigned
12377
+ * to the key.
12378
+ */
12379
+ set key(value) {
12380
+ this._key = value;
12381
+ }
12382
+ /**
12383
+ * The function returns the value stored in a variable, or undefined if the variable is empty.
12384
+ * @returns The value of the variable `_value` is being returned.
12385
+ */
12386
+ get value() {
12387
+ return this._value;
12388
+ }
12389
+ /**
12390
+ * The function sets the value of a variable.
12391
+ * @param {V | undefined} value - The parameter "value" is of type "V | undefined", which means it
12392
+ * can accept a value of type "V" or it can be undefined.
12393
+ */
12394
+ set value(value) {
12395
+ this._value = value;
12396
+ }
12397
+ /**
12398
+ * The function returns an array of TreeNode objects or undefined.
12399
+ * @returns The `children` property is being returned. It is of type `TreeNode<V>[] | undefined`,
12400
+ * which means it can either be an array of `TreeNode<V>` objects or `undefined`.
12401
+ */
12402
+ get children() {
12403
+ return this._children;
12404
+ }
12405
+ /**
12406
+ * The function sets the value of the children property of a TreeNode object.
12407
+ * @param {TreeNode<V>[] | undefined} value - The value parameter is of type TreeNode<V>[] |
12408
+ * undefined. This means that it can accept an array of TreeNode objects or undefined.
12409
+ */
12410
+ set children(value) {
12411
+ this._children = value;
11680
12412
  }
12413
+ /**
12414
+ * The function `addChildren` adds one or more child nodes to the current node.
12415
+ * @param {TreeNode<V> | TreeNode<V>[]} children - The `children` parameter can be either a single
12416
+ * `TreeNode<V>` object or an array of `TreeNode<V>` objects.
12417
+ */
11681
12418
  addChildren(children) {
11682
- if (!this.children) {
11683
- this.children = [];
12419
+ if (!this._children) {
12420
+ this._children = [];
11684
12421
  }
11685
12422
  if (children instanceof _TreeNode) {
11686
- this.children.push(children);
12423
+ this._children.push(children);
11687
12424
  } else {
11688
- this.children = this.children.concat(children);
12425
+ this._children = this._children.concat(children);
11689
12426
  }
11690
12427
  }
12428
+ /**
12429
+ * The function `getHeight()` calculates the maximum depth of a tree structure by performing a
12430
+ * breadth-first search.
12431
+ * @returns the maximum depth or height of the tree.
12432
+ */
11691
12433
  getHeight() {
11692
12434
  let maxDepth = 0;
11693
12435
  if (this) {
@@ -11695,10 +12437,10 @@ var dataStructureTyped = (() => {
11695
12437
  if (level > maxDepth) {
11696
12438
  maxDepth = level;
11697
12439
  }
11698
- const { children } = node;
11699
- if (children) {
11700
- for (let i = 0, len = children.length; i < len; i++) {
11701
- bfs(children[i], level + 1);
12440
+ const { _children } = node;
12441
+ if (_children) {
12442
+ for (let i = 0, len = _children.length; i < len; i++) {
12443
+ bfs(_children[i], level + 1);
11702
12444
  }
11703
12445
  }
11704
12446
  };
@@ -11710,6 +12452,14 @@ var dataStructureTyped = (() => {
11710
12452
 
11711
12453
  // src/data-structures/priority-queue/priority-queue.ts
11712
12454
  var PriorityQueue = class extends Heap {
12455
+ /**
12456
+ * The constructor initializes a priority queue with optional elements and options.
12457
+ * @param elements - The `elements` parameter is an iterable object that contains the initial
12458
+ * elements to be added to the priority queue. It is an optional parameter and if not provided, the
12459
+ * priority queue will be initialized as empty.
12460
+ * @param [options] - The `options` parameter is an optional object that can be used to customize the
12461
+ * behavior of the priority queue. It can contain the following properties:
12462
+ */
11713
12463
  constructor(elements = [], options) {
11714
12464
  super(elements, options);
11715
12465
  }
@@ -11717,6 +12467,17 @@ var dataStructureTyped = (() => {
11717
12467
 
11718
12468
  // src/data-structures/priority-queue/min-priority-queue.ts
11719
12469
  var MinPriorityQueue = class extends PriorityQueue {
12470
+ /**
12471
+ * The constructor initializes a PriorityQueue with optional elements and options, including a
12472
+ * comparator function.
12473
+ * @param elements - The `elements` parameter is an iterable object that contains the initial
12474
+ * elements to be added to the priority queue. It is optional and defaults to an empty array if not
12475
+ * provided.
12476
+ * @param options - The `options` parameter is an object that contains additional configuration
12477
+ * options for the priority queue. In this case, it has a property called `comparator` which is a
12478
+ * function used to compare elements in the priority queue. The `comparator` function takes two
12479
+ * parameters `a` and `b`,
12480
+ */
11720
12481
  constructor(elements = [], options = {
11721
12482
  comparator: (a, b) => {
11722
12483
  if (!(typeof a === "number" && typeof b === "number")) {
@@ -11732,6 +12493,16 @@ var dataStructureTyped = (() => {
11732
12493
 
11733
12494
  // src/data-structures/priority-queue/max-priority-queue.ts
11734
12495
  var MaxPriorityQueue = class extends PriorityQueue {
12496
+ /**
12497
+ * The constructor initializes a PriorityQueue with optional elements and options, including a
12498
+ * comparator function.
12499
+ * @param elements - The `elements` parameter is an iterable object that contains the initial
12500
+ * elements to be added to the priority queue. It is optional and defaults to an empty array if not
12501
+ * provided.
12502
+ * @param options - The `options` parameter is an object that contains additional configuration
12503
+ * options for the priority queue. In this case, it has a property called `comparator` which is a
12504
+ * function used to compare elements in the priority queue.
12505
+ */
11735
12506
  constructor(elements = [], options = {
11736
12507
  comparator: (a, b) => {
11737
12508
  if (!(typeof a === "number" && typeof b === "number")) {
@@ -11796,7 +12567,7 @@ var dataStructureTyped = (() => {
11796
12567
  return this._rows;
11797
12568
  }
11798
12569
  /**
11799
- * The function returns the value of the private variable _cols.
12570
+ * The function returns the value of the protected variable _cols.
11800
12571
  * @returns The number of columns.
11801
12572
  */
11802
12573
  get cols() {
@@ -12291,12 +13062,60 @@ var dataStructureTyped = (() => {
12291
13062
  // src/data-structures/trie/trie.ts
12292
13063
  var TrieNode = class {
12293
13064
  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();
13065
+ __publicField(this, "_key");
13066
+ __publicField(this, "_children");
13067
+ __publicField(this, "_isEnd");
13068
+ this._key = key;
13069
+ this._isEnd = false;
13070
+ this._children = /* @__PURE__ */ new Map();
13071
+ }
13072
+ /**
13073
+ * The function returns the value of the protected variable _key.
13074
+ * @returns The value of the `_key` property, which is a string.
13075
+ */
13076
+ get key() {
13077
+ return this._key;
13078
+ }
13079
+ /**
13080
+ * The above function sets the value of a protected variable called "key".
13081
+ * @param {string} value - The value parameter is a string that represents the value to be assigned
13082
+ * to the key.
13083
+ */
13084
+ set key(value) {
13085
+ this._key = value;
13086
+ }
13087
+ /**
13088
+ * The function returns the children of a TrieNode as a Map.
13089
+ * @returns The `children` property of the TrieNode object, which is a Map containing string keys and
13090
+ * TrieNode values.
13091
+ */
13092
+ get children() {
13093
+ return this._children;
13094
+ }
13095
+ /**
13096
+ * The function sets the value of the `_children` property of a TrieNode object.
13097
+ * @param value - The value parameter is a Map object that represents the children of a TrieNode. The
13098
+ * keys of the map are strings, which represent the characters that are associated with each child
13099
+ * TrieNode. The values of the map are TrieNode objects, which represent the child nodes of the
13100
+ * current TrieNode.
13101
+ */
13102
+ set children(value) {
13103
+ this._children = value;
13104
+ }
13105
+ /**
13106
+ * The function returns a boolean value indicating whether a certain condition is met.
13107
+ * @returns The method is returning a boolean value, specifically the value of the variable `_isEnd`.
13108
+ */
13109
+ get isEnd() {
13110
+ return this._isEnd;
13111
+ }
13112
+ /**
13113
+ * The function sets the value of the "_isEnd" property.
13114
+ * @param {boolean} value - The value parameter is a boolean value that indicates whether the current
13115
+ * state is the end state or not.
13116
+ */
13117
+ set isEnd(value) {
13118
+ this._isEnd = value;
12300
13119
  }
12301
13120
  };
12302
13121
  var Trie = class _Trie extends IterableElementBase {
@@ -12329,9 +13148,8 @@ var dataStructureTyped = (() => {
12329
13148
  return this._size;
12330
13149
  }
12331
13150
  /**
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
13151
+ * The caseSensitive function is a getter that returns the value of the protected _caseSensitive property.
13152
+ * @return The value of the _caseSensitive protected variable
12335
13153
  */
12336
13154
  get caseSensitive() {
12337
13155
  return this._caseSensitive;
@@ -12344,12 +13162,12 @@ var dataStructureTyped = (() => {
12344
13162
  return this._root;
12345
13163
  }
12346
13164
  /**
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.
13165
+ * Time Complexity: O(l), where l is the length of the word being added.
13166
+ * Space Complexity: O(l) - Each character in the word adds a TrieNode.
12349
13167
  */
12350
13168
  /**
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.
13169
+ * Time Complexity: O(l), where l is the length of the word being added.
13170
+ * Space Complexity: O(l) - Each character in the word adds a TrieNode.
12353
13171
  *
12354
13172
  * Add a word to the Trie structure.
12355
13173
  * @param {string} word - The word to add.
@@ -12375,11 +13193,11 @@ var dataStructureTyped = (() => {
12375
13193
  return isNewWord;
12376
13194
  }
12377
13195
  /**
12378
- * Time Complexity: O(M), where M is the length of the input word.
13196
+ * Time Complexity: O(l), where l is the length of the input word.
12379
13197
  * Space Complexity: O(1) - Constant space.
12380
13198
  */
12381
13199
  /**
12382
- * Time Complexity: O(M), where M is the length of the input word.
13200
+ * Time Complexity: O(l), where l is the length of the input word.
12383
13201
  * Space Complexity: O(1) - Constant space.
12384
13202
  *
12385
13203
  * Check if the Trie contains a given word.
@@ -12398,6 +13216,13 @@ var dataStructureTyped = (() => {
12398
13216
  return cur.isEnd;
12399
13217
  }
12400
13218
  /**
13219
+ * Time Complexity: O(1)
13220
+ * Space Complexity: O(1)
13221
+ */
13222
+ /**
13223
+ * Time Complexity: O(1)
13224
+ * Space Complexity: O(1)
13225
+ *
12401
13226
  * The isEmpty function checks if the size of the queue is 0.
12402
13227
  * @return True if the size of the queue is 0
12403
13228
  */
@@ -12405,12 +13230,26 @@ var dataStructureTyped = (() => {
12405
13230
  return this.size === 0;
12406
13231
  }
12407
13232
  /**
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.
13233
+ * Time Complexity: O(1)
13234
+ * Space Complexity: O(1)
13235
+ */
13236
+ /**
13237
+ * Time Complexity: O(1)
13238
+ * Space Complexity: O(1)
13239
+ *
13240
+ * The clear function resets the size of the Trie to 0 and creates a new root TrieNode.
13241
+ */
13242
+ clear() {
13243
+ this._size = 0;
13244
+ this._root = new TrieNode("");
13245
+ }
13246
+ /**
13247
+ * Time Complexity: O(l), where l is the length of the word being deleted.
13248
+ * Space Complexity: O(n) - Due to the recursive DFS approach.
12410
13249
  */
12411
13250
  /**
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.
13251
+ * Time Complexity: O(l), where l is the length of the word being deleted.
13252
+ * Space Complexity: O(n) - Due to the recursive DFS approach.
12414
13253
  *
12415
13254
  * Remove a word from the Trie structure.
12416
13255
  * @param{string} word - The word to delete.
@@ -12451,11 +13290,11 @@ var dataStructureTyped = (() => {
12451
13290
  return isDeleted;
12452
13291
  }
12453
13292
  /**
12454
- * Time Complexity: O(N), where N is the total number of nodes in the trie.
13293
+ * Time Complexity: O(n), where n is the total number of nodes in the trie.
12455
13294
  * Space Complexity: O(1) - Constant space.
12456
13295
  */
12457
13296
  /**
12458
- * Time Complexity: O(N), where N is the total number of nodes in the trie.
13297
+ * Time Complexity: O(n), where n is the total number of nodes in the trie.
12459
13298
  * Space Complexity: O(1) - Constant space.
12460
13299
  *
12461
13300
  */
@@ -12479,11 +13318,11 @@ var dataStructureTyped = (() => {
12479
13318
  return maxDepth;
12480
13319
  }
12481
13320
  /**
12482
- * Time Complexity: O(M), where M is the length of the input prefix.
13321
+ * Time Complexity: O(l), where l is the length of the input prefix.
12483
13322
  * Space Complexity: O(1) - Constant space.
12484
13323
  */
12485
13324
  /**
12486
- * Time Complexity: O(M), where M is the length of the input prefix.
13325
+ * Time Complexity: O(l), where l is the length of the input prefix.
12487
13326
  * Space Complexity: O(1) - Constant space.
12488
13327
  *
12489
13328
  * Check if a given input string has an absolute prefix in the Trie, meaning it's not a complete word.
@@ -12502,11 +13341,11 @@ var dataStructureTyped = (() => {
12502
13341
  return !cur.isEnd;
12503
13342
  }
12504
13343
  /**
12505
- * Time Complexity: O(M), where M is the length of the input prefix.
13344
+ * Time Complexity: O(l), where l is the length of the input prefix.
12506
13345
  * Space Complexity: O(1) - Constant space.
12507
13346
  */
12508
13347
  /**
12509
- * Time Complexity: O(M), where M is the length of the input prefix.
13348
+ * Time Complexity: O(l), where l is the length of the input prefix.
12510
13349
  * Space Complexity: O(1) - Constant space.
12511
13350
  *
12512
13351
  * 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 +13364,12 @@ var dataStructureTyped = (() => {
12525
13364
  return true;
12526
13365
  }
12527
13366
  /**
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.
13367
+ * Time Complexity: O(n), where n is the total number of nodes in the trie.
13368
+ * Space Complexity: O(l), where l is the length of the input prefix.
12530
13369
  */
12531
13370
  /**
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.
13371
+ * Time Complexity: O(n), where n is the total number of nodes in the trie.
13372
+ * Space Complexity: O(l), where l is the length of the input prefix.
12534
13373
  *
12535
13374
  * 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
13375
  * @param {string} input - The input string representing the common prefix to check for.
@@ -12554,12 +13393,12 @@ var dataStructureTyped = (() => {
12554
13393
  return commonPre === input;
12555
13394
  }
12556
13395
  /**
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.
13396
+ * Time Complexity: O(n), where n is the total number of nodes in the trie.
13397
+ * Space Complexity: O(l), where l is the length of the longest common prefix.
12559
13398
  */
12560
13399
  /**
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.
13400
+ * Time Complexity: O(n), where n is the total number of nodes in the trie.
13401
+ * Space Complexity: O(l), where l is the length of the longest common prefix.
12563
13402
  *
12564
13403
  * Get the longest common prefix among all the words stored in the Trie.
12565
13404
  * @returns {string} The longest common prefix found in the Trie.
@@ -12579,12 +13418,12 @@ var dataStructureTyped = (() => {
12579
13418
  return commonPre;
12580
13419
  }
12581
13420
  /**
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.
13421
+ * Time Complexity: O(w * l), where w is the number of words retrieved, and l is the average length of the words.
13422
+ * Space Complexity: O(w * l) - The space required for the output array.
12584
13423
  */
12585
13424
  /**
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.
13425
+ * Time Complexity: O(w * l), where w is the number of words retrieved, and l is the average length of the words.
13426
+ * Space Complexity: O(w * l) - The space required for the output array.
12588
13427
  *
12589
13428
  * The `getAll` function returns an array of all words in a Trie data structure that start with a given prefix.
12590
13429
  * @param {string} prefix - The `prefix` parameter is a string that represents the prefix that we want to search for in the
@@ -12693,6 +13532,17 @@ var dataStructureTyped = (() => {
12693
13532
  }
12694
13533
  return newTrie;
12695
13534
  }
13535
+ /**
13536
+ * Time Complexity: O(n)
13537
+ * Space Complexity: O(n)
13538
+ */
13539
+ /**
13540
+ * Time Complexity: O(n)
13541
+ * Space Complexity: O(n)
13542
+ *
13543
+ * The function `_getIterator` returns an iterable iterator that performs a depth-first search on a
13544
+ * trie data structure and yields all the paths to the end nodes.
13545
+ */
12696
13546
  *_getIterator() {
12697
13547
  function* _dfs(node, path) {
12698
13548
  if (node.isEnd) {
@@ -12705,11 +13555,11 @@ var dataStructureTyped = (() => {
12705
13555
  yield* __yieldStar(_dfs(this.root, ""));
12706
13556
  }
12707
13557
  /**
12708
- * Time Complexity: O(M), where M is the length of the input string.
13558
+ * Time Complexity: O(l), where l is the length of the input string.
12709
13559
  * Space Complexity: O(1) - Constant space.
12710
13560
  */
12711
13561
  /**
12712
- * Time Complexity: O(M), where M is the length of the input string.
13562
+ * Time Complexity: O(l), where l is the length of the input string.
12713
13563
  * Space Complexity: O(1) - Constant space.
12714
13564
  *
12715
13565
  * @param str