data-structure-typed 1.50.2 → 1.50.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (203) hide show
  1. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -13
  2. package/CHANGELOG.md +1 -1
  3. package/README.md +23 -21
  4. package/README_zh-CN.md +7 -7
  5. package/SPECIFICATION.md +56 -0
  6. package/SPONSOR-zh-CN.md +90 -0
  7. package/SPONSOR.md +54 -0
  8. package/benchmark/report.html +13 -13
  9. package/benchmark/report.json +149 -155
  10. package/dist/cjs/data-structures/base/iterable-base.d.ts +6 -0
  11. package/dist/cjs/data-structures/base/iterable-base.js.map +1 -1
  12. package/dist/cjs/data-structures/binary-tree/{tree-multimap.d.ts → avl-tree-multi-map.d.ts} +43 -10
  13. package/dist/cjs/data-structures/binary-tree/{tree-multimap.js → avl-tree-multi-map.js} +50 -12
  14. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js.map +1 -0
  15. package/dist/cjs/data-structures/binary-tree/avl-tree.d.ts +29 -1
  16. package/dist/cjs/data-structures/binary-tree/avl-tree.js +33 -1
  17. package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +1 -1
  18. package/dist/cjs/data-structures/binary-tree/binary-indexed-tree.d.ts +22 -0
  19. package/dist/cjs/data-structures/binary-tree/binary-indexed-tree.js +22 -0
  20. package/dist/cjs/data-structures/binary-tree/binary-indexed-tree.js.map +1 -1
  21. package/dist/cjs/data-structures/binary-tree/binary-tree.d.ts +1 -1
  22. package/dist/cjs/data-structures/binary-tree/binary-tree.js +1 -1
  23. package/dist/cjs/data-structures/binary-tree/bst.d.ts +46 -13
  24. package/dist/cjs/data-structures/binary-tree/bst.js +51 -20
  25. package/dist/cjs/data-structures/binary-tree/bst.js.map +1 -1
  26. package/dist/cjs/data-structures/binary-tree/index.d.ts +2 -1
  27. package/dist/cjs/data-structures/binary-tree/index.js +2 -1
  28. package/dist/cjs/data-structures/binary-tree/index.js.map +1 -1
  29. package/dist/cjs/data-structures/binary-tree/rb-tree.d.ts +54 -2
  30. package/dist/cjs/data-structures/binary-tree/rb-tree.js +90 -24
  31. package/dist/cjs/data-structures/binary-tree/rb-tree.js.map +1 -1
  32. package/dist/cjs/data-structures/binary-tree/segment-tree.d.ts +99 -6
  33. package/dist/cjs/data-structures/binary-tree/segment-tree.js +127 -10
  34. package/dist/cjs/data-structures/binary-tree/segment-tree.js.map +1 -1
  35. package/dist/cjs/data-structures/binary-tree/tree-multi-map.d.ts +200 -0
  36. package/dist/cjs/data-structures/binary-tree/tree-multi-map.js +400 -0
  37. package/dist/cjs/data-structures/binary-tree/tree-multi-map.js.map +1 -0
  38. package/dist/cjs/data-structures/graph/abstract-graph.d.ts +0 -78
  39. package/dist/cjs/data-structures/graph/abstract-graph.js +0 -189
  40. package/dist/cjs/data-structures/graph/abstract-graph.js.map +1 -1
  41. package/dist/cjs/data-structures/graph/directed-graph.d.ts +59 -0
  42. package/dist/cjs/data-structures/graph/directed-graph.js +105 -0
  43. package/dist/cjs/data-structures/graph/directed-graph.js.map +1 -1
  44. package/dist/cjs/data-structures/graph/undirected-graph.d.ts +60 -7
  45. package/dist/cjs/data-structures/graph/undirected-graph.js +126 -18
  46. package/dist/cjs/data-structures/graph/undirected-graph.js.map +1 -1
  47. package/dist/cjs/data-structures/hash/hash-map.d.ts +143 -23
  48. package/dist/cjs/data-structures/hash/hash-map.js +196 -62
  49. package/dist/cjs/data-structures/hash/hash-map.js.map +1 -1
  50. package/dist/cjs/data-structures/heap/heap.d.ts +29 -19
  51. package/dist/cjs/data-structures/heap/heap.js +29 -20
  52. package/dist/cjs/data-structures/heap/heap.js.map +1 -1
  53. package/dist/cjs/data-structures/linked-list/doubly-linked-list.d.ts +71 -25
  54. package/dist/cjs/data-structures/linked-list/doubly-linked-list.js +83 -25
  55. package/dist/cjs/data-structures/linked-list/doubly-linked-list.js.map +1 -1
  56. package/dist/cjs/data-structures/linked-list/singly-linked-list.d.ts +26 -3
  57. package/dist/cjs/data-structures/linked-list/singly-linked-list.js +34 -3
  58. package/dist/cjs/data-structures/linked-list/singly-linked-list.js.map +1 -1
  59. package/dist/cjs/data-structures/linked-list/skip-linked-list.d.ts +2 -2
  60. package/dist/cjs/data-structures/linked-list/skip-linked-list.js +2 -2
  61. package/dist/cjs/data-structures/matrix/matrix.d.ts +1 -1
  62. package/dist/cjs/data-structures/matrix/matrix.js +1 -1
  63. package/dist/cjs/data-structures/priority-queue/max-priority-queue.d.ts +10 -0
  64. package/dist/cjs/data-structures/priority-queue/max-priority-queue.js +10 -0
  65. package/dist/cjs/data-structures/priority-queue/max-priority-queue.js.map +1 -1
  66. package/dist/cjs/data-structures/priority-queue/min-priority-queue.d.ts +11 -0
  67. package/dist/cjs/data-structures/priority-queue/min-priority-queue.js +11 -0
  68. package/dist/cjs/data-structures/priority-queue/min-priority-queue.js.map +1 -1
  69. package/dist/cjs/data-structures/priority-queue/priority-queue.d.ts +8 -0
  70. package/dist/cjs/data-structures/priority-queue/priority-queue.js +8 -0
  71. package/dist/cjs/data-structures/priority-queue/priority-queue.js.map +1 -1
  72. package/dist/cjs/data-structures/queue/deque.d.ts +95 -21
  73. package/dist/cjs/data-structures/queue/deque.js +100 -16
  74. package/dist/cjs/data-structures/queue/deque.js.map +1 -1
  75. package/dist/cjs/data-structures/queue/queue.d.ts +65 -45
  76. package/dist/cjs/data-structures/queue/queue.js +65 -45
  77. package/dist/cjs/data-structures/queue/queue.js.map +1 -1
  78. package/dist/cjs/data-structures/stack/stack.d.ts +36 -22
  79. package/dist/cjs/data-structures/stack/stack.js +36 -22
  80. package/dist/cjs/data-structures/stack/stack.js.map +1 -1
  81. package/dist/cjs/data-structures/tree/tree.d.ts +57 -3
  82. package/dist/cjs/data-structures/tree/tree.js +77 -11
  83. package/dist/cjs/data-structures/tree/tree.js.map +1 -1
  84. package/dist/cjs/data-structures/trie/trie.d.ts +100 -36
  85. package/dist/cjs/data-structures/trie/trie.js +115 -36
  86. package/dist/cjs/data-structures/trie/trie.js.map +1 -1
  87. package/dist/cjs/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +5 -0
  88. package/dist/cjs/types/data-structures/binary-tree/avl-tree-multi-map.js +3 -0
  89. package/dist/cjs/types/data-structures/binary-tree/avl-tree-multi-map.js.map +1 -0
  90. package/dist/cjs/types/data-structures/binary-tree/index.d.ts +2 -1
  91. package/dist/cjs/types/data-structures/binary-tree/index.js +2 -1
  92. package/dist/cjs/types/data-structures/binary-tree/index.js.map +1 -1
  93. package/dist/cjs/types/data-structures/binary-tree/tree-multi-map.d.ts +5 -0
  94. package/dist/cjs/types/data-structures/binary-tree/{tree-multimap.js → tree-multi-map.js} +1 -1
  95. package/dist/cjs/types/data-structures/binary-tree/tree-multi-map.js.map +1 -0
  96. package/dist/mjs/data-structures/base/iterable-base.d.ts +6 -0
  97. package/dist/mjs/data-structures/binary-tree/{tree-multimap.d.ts → avl-tree-multi-map.d.ts} +43 -10
  98. package/dist/mjs/data-structures/binary-tree/{tree-multimap.js → avl-tree-multi-map.js} +46 -9
  99. package/dist/mjs/data-structures/binary-tree/avl-tree.d.ts +29 -1
  100. package/dist/mjs/data-structures/binary-tree/avl-tree.js +34 -2
  101. package/dist/mjs/data-structures/binary-tree/binary-indexed-tree.d.ts +22 -0
  102. package/dist/mjs/data-structures/binary-tree/binary-indexed-tree.js +22 -0
  103. package/dist/mjs/data-structures/binary-tree/binary-tree.d.ts +1 -1
  104. package/dist/mjs/data-structures/binary-tree/binary-tree.js +1 -1
  105. package/dist/mjs/data-structures/binary-tree/bst.d.ts +46 -13
  106. package/dist/mjs/data-structures/binary-tree/bst.js +51 -20
  107. package/dist/mjs/data-structures/binary-tree/index.d.ts +2 -1
  108. package/dist/mjs/data-structures/binary-tree/index.js +2 -1
  109. package/dist/mjs/data-structures/binary-tree/rb-tree.d.ts +54 -2
  110. package/dist/mjs/data-structures/binary-tree/rb-tree.js +91 -25
  111. package/dist/mjs/data-structures/binary-tree/segment-tree.d.ts +99 -6
  112. package/dist/mjs/data-structures/binary-tree/segment-tree.js +127 -10
  113. package/dist/mjs/data-structures/binary-tree/tree-multi-map.d.ts +200 -0
  114. package/dist/mjs/data-structures/binary-tree/tree-multi-map.js +397 -0
  115. package/dist/mjs/data-structures/graph/abstract-graph.d.ts +0 -78
  116. package/dist/mjs/data-structures/graph/abstract-graph.js +0 -188
  117. package/dist/mjs/data-structures/graph/directed-graph.d.ts +59 -0
  118. package/dist/mjs/data-structures/graph/directed-graph.js +105 -0
  119. package/dist/mjs/data-structures/graph/undirected-graph.d.ts +60 -7
  120. package/dist/mjs/data-structures/graph/undirected-graph.js +127 -19
  121. package/dist/mjs/data-structures/hash/hash-map.d.ts +143 -23
  122. package/dist/mjs/data-structures/hash/hash-map.js +204 -70
  123. package/dist/mjs/data-structures/heap/heap.d.ts +29 -19
  124. package/dist/mjs/data-structures/heap/heap.js +29 -20
  125. package/dist/mjs/data-structures/linked-list/doubly-linked-list.d.ts +71 -25
  126. package/dist/mjs/data-structures/linked-list/doubly-linked-list.js +86 -28
  127. package/dist/mjs/data-structures/linked-list/singly-linked-list.d.ts +26 -3
  128. package/dist/mjs/data-structures/linked-list/singly-linked-list.js +36 -5
  129. package/dist/mjs/data-structures/linked-list/skip-linked-list.d.ts +2 -2
  130. package/dist/mjs/data-structures/linked-list/skip-linked-list.js +2 -2
  131. package/dist/mjs/data-structures/matrix/matrix.d.ts +1 -1
  132. package/dist/mjs/data-structures/matrix/matrix.js +1 -1
  133. package/dist/mjs/data-structures/priority-queue/max-priority-queue.d.ts +10 -0
  134. package/dist/mjs/data-structures/priority-queue/max-priority-queue.js +10 -0
  135. package/dist/mjs/data-structures/priority-queue/min-priority-queue.d.ts +11 -0
  136. package/dist/mjs/data-structures/priority-queue/min-priority-queue.js +11 -0
  137. package/dist/mjs/data-structures/priority-queue/priority-queue.d.ts +8 -0
  138. package/dist/mjs/data-structures/priority-queue/priority-queue.js +8 -0
  139. package/dist/mjs/data-structures/queue/deque.d.ts +95 -21
  140. package/dist/mjs/data-structures/queue/deque.js +105 -21
  141. package/dist/mjs/data-structures/queue/queue.d.ts +65 -45
  142. package/dist/mjs/data-structures/queue/queue.js +65 -45
  143. package/dist/mjs/data-structures/stack/stack.d.ts +36 -22
  144. package/dist/mjs/data-structures/stack/stack.js +36 -22
  145. package/dist/mjs/data-structures/tree/tree.d.ts +57 -3
  146. package/dist/mjs/data-structures/tree/tree.js +80 -14
  147. package/dist/mjs/data-structures/trie/trie.d.ts +100 -36
  148. package/dist/mjs/data-structures/trie/trie.js +118 -39
  149. package/dist/mjs/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +5 -0
  150. package/dist/mjs/types/data-structures/binary-tree/index.d.ts +2 -1
  151. package/dist/mjs/types/data-structures/binary-tree/index.js +2 -1
  152. package/dist/mjs/types/data-structures/binary-tree/tree-multi-map.d.ts +5 -0
  153. package/dist/mjs/types/data-structures/binary-tree/tree-multi-map.js +1 -0
  154. package/dist/umd/data-structure-typed.js +1876 -656
  155. package/dist/umd/data-structure-typed.min.js +2 -2
  156. package/dist/umd/data-structure-typed.min.js.map +1 -1
  157. package/package.json +59 -58
  158. package/src/data-structures/base/iterable-base.ts +12 -0
  159. package/src/data-structures/binary-tree/{tree-multimap.ts → avl-tree-multi-map.ts} +59 -20
  160. package/src/data-structures/binary-tree/avl-tree.ts +37 -3
  161. package/src/data-structures/binary-tree/binary-indexed-tree.ts +22 -0
  162. package/src/data-structures/binary-tree/binary-tree.ts +1 -1
  163. package/src/data-structures/binary-tree/bst.ts +51 -19
  164. package/src/data-structures/binary-tree/index.ts +2 -1
  165. package/src/data-structures/binary-tree/rb-tree.ts +99 -28
  166. package/src/data-structures/binary-tree/segment-tree.ts +145 -11
  167. package/src/data-structures/binary-tree/tree-multi-map.ts +463 -0
  168. package/src/data-structures/graph/abstract-graph.ts +0 -211
  169. package/src/data-structures/graph/directed-graph.ts +122 -0
  170. package/src/data-structures/graph/undirected-graph.ts +143 -19
  171. package/src/data-structures/hash/hash-map.ts +228 -76
  172. package/src/data-structures/heap/heap.ts +31 -20
  173. package/src/data-structures/linked-list/doubly-linked-list.ts +96 -29
  174. package/src/data-structures/linked-list/singly-linked-list.ts +42 -6
  175. package/src/data-structures/linked-list/skip-linked-list.ts +2 -2
  176. package/src/data-structures/matrix/matrix.ts +1 -1
  177. package/src/data-structures/priority-queue/max-priority-queue.ts +10 -0
  178. package/src/data-structures/priority-queue/min-priority-queue.ts +11 -0
  179. package/src/data-structures/priority-queue/priority-queue.ts +8 -0
  180. package/src/data-structures/queue/deque.ts +118 -22
  181. package/src/data-structures/queue/queue.ts +68 -45
  182. package/src/data-structures/stack/stack.ts +39 -23
  183. package/src/data-structures/tree/tree.ts +89 -15
  184. package/src/data-structures/trie/trie.ts +131 -40
  185. package/src/types/data-structures/binary-tree/avl-tree-multi-map.ts +8 -0
  186. package/src/types/data-structures/binary-tree/index.ts +2 -1
  187. package/src/types/data-structures/binary-tree/tree-multi-map.ts +8 -0
  188. package/test/integration/index.html +2 -2
  189. package/test/performance/data-structures/graph/directed-graph.test.ts +1 -1
  190. package/test/unit/data-structures/binary-tree/{tree-multimap.test.ts → avl-tree-multi-map.test.ts} +55 -55
  191. package/test/unit/data-structures/binary-tree/overall.test.ts +24 -25
  192. package/test/unit/data-structures/binary-tree/tree-multi-map.test.ts +706 -0
  193. package/test/unit/data-structures/graph/abstract-graph.test.ts +3 -0
  194. package/test/unit/data-structures/graph/directed-graph.test.ts +189 -253
  195. package/test/unit/data-structures/graph/undirected-graph.test.ts +263 -18
  196. package/test/unit/data-structures/queue/queue.test.ts +2 -0
  197. package/test/unit/unrestricted-interconversion.test.ts +3 -3
  198. package/dist/cjs/data-structures/binary-tree/tree-multimap.js.map +0 -1
  199. package/dist/cjs/types/data-structures/binary-tree/tree-multimap.d.ts +0 -5
  200. package/dist/cjs/types/data-structures/binary-tree/tree-multimap.js.map +0 -1
  201. package/dist/mjs/types/data-structures/binary-tree/tree-multimap.d.ts +0 -5
  202. package/src/types/data-structures/binary-tree/tree-multimap.ts +0 -8
  203. /package/dist/mjs/types/data-structures/binary-tree/{tree-multimap.js → avl-tree-multi-map.js} +0 -0
@@ -15,12 +15,6 @@ import { IterableElementBase } from '../base';
15
15
  * 5. Performance jitter: Deque may experience performance jitter, but DoublyLinkedList will not
16
16
  */
17
17
  export declare class Deque<E> extends IterableElementBase<E> {
18
- protected _bucketFirst: number;
19
- protected _firstInBucket: number;
20
- protected _bucketLast: number;
21
- protected _lastInBucket: number;
22
- protected _bucketCount: number;
23
- protected readonly _bucketSize: number;
24
18
  /**
25
19
  * The constructor initializes a Deque object with an optional iterable of elements and options.
26
20
  * @param elements - An iterable object (such as an array or a Set) that contains the initial
@@ -33,16 +27,48 @@ export declare class Deque<E> extends IterableElementBase<E> {
33
27
  * or is not a number
34
28
  */
35
29
  constructor(elements?: IterableWithSizeOrLength<E>, options?: DequeOptions);
30
+ protected _bucketSize: number;
36
31
  /**
37
32
  * The bucketSize function returns the size of the bucket.
38
33
  *
39
34
  * @return The size of the bucket
40
35
  */
41
36
  get bucketSize(): number;
37
+ protected _bucketFirst: number;
38
+ /**
39
+ * The function returns the value of the protected variable `_bucketFirst`.
40
+ * @returns The value of the `_bucketFirst` property.
41
+ */
42
+ get bucketFirst(): number;
43
+ protected _firstInBucket: number;
44
+ /**
45
+ * The function returns the value of the protected variable _firstInBucket.
46
+ * @returns The method is returning the value of the variable `_firstInBucket`, which is of type
47
+ * `number`.
48
+ */
49
+ get firstInBucket(): number;
50
+ protected _bucketLast: number;
51
+ /**
52
+ * The function returns the value of the protected variable `_bucketLast`.
53
+ * @returns The value of the `_bucketLast` property, which is a number.
54
+ */
55
+ get bucketLast(): number;
56
+ protected _lastInBucket: number;
57
+ /**
58
+ * The function returns the value of the protected variable _lastInBucket.
59
+ * @returns The method is returning the value of the variable `_lastInBucket`, which is of type
60
+ * `number`.
61
+ */
62
+ get lastInBucket(): number;
63
+ protected _bucketCount: number;
64
+ /**
65
+ * The function returns the number of buckets.
66
+ * @returns The number of buckets.
67
+ */
68
+ get bucketCount(): number;
42
69
  protected _buckets: E[][];
43
70
  /**
44
71
  * The buckets function returns the buckets property of the object.
45
- *
46
72
  * @return The buckets property
47
73
  */
48
74
  get buckets(): E[][];
@@ -120,11 +146,25 @@ export declare class Deque<E> extends IterableElementBase<E> {
120
146
  */
121
147
  shift(): E | undefined;
122
148
  /**
123
- * Time Complexity: O(1) - Removes the last element.
124
- * Space Complexity: O(1) - Operates in-place.
149
+ * Time Complexity: O(1)
150
+ * Space Complexity: O(1)
151
+ */
152
+ /**
153
+ * Time Complexity: O(1)
154
+ * Space Complexity: O(1)
155
+ *
156
+ * The function checks if the size of an object is equal to zero and returns a boolean value.
157
+ * @returns A boolean value indicating whether the size of the object is 0 or not.
125
158
  */
126
159
  isEmpty(): boolean;
127
160
  /**
161
+ * Time Complexity: O(1)
162
+ * Space Complexity: O(1)
163
+ */
164
+ /**
165
+ * Time Complexity: O(1)
166
+ * Space Complexity: O(1)
167
+ *
128
168
  * The clear() function resets the state of the object by initializing all variables to their default
129
169
  * values.
130
170
  */
@@ -204,14 +244,33 @@ export declare class Deque<E> extends IterableElementBase<E> {
204
244
  * @returns The method is returning the updated size of the data structure.
205
245
  */
206
246
  cut(pos: number, isCutSelf?: boolean): Deque<E>;
247
+ /**
248
+ * Time Complexity: O(1)
249
+ * Space Complexity: O(1) or O(n)
250
+ */
251
+ /**
252
+ * Time Complexity: O(1)
253
+ * Space Complexity: O(1) or O(n)
254
+ *
255
+ * The `cutRest` function cuts the elements from a specified position in a deque and returns a new
256
+ * deque with the cut elements.
257
+ * @param {number} pos - The `pos` parameter represents the position from which to cut the Deque. It
258
+ * is a number that indicates the index of the element in the Deque where the cut should start.
259
+ * @param [isCutSelf=false] - isCutSelf is a boolean parameter that determines whether the original
260
+ * Deque should be modified or a new Deque should be created. If isCutSelf is true, the original
261
+ * Deque will be modified by cutting off elements starting from the specified position. If isCutSelf
262
+ * is false, a new De
263
+ * @returns The function `cutRest` returns either the modified original deque (`this`) or a new deque
264
+ * (`newDeque`) depending on the value of the `isCutSelf` parameter.
265
+ */
207
266
  cutRest(pos: number, isCutSelf?: boolean): Deque<E>;
208
267
  /**
209
268
  * Time Complexity: O(n)
210
- * Space Complexity: O(1)
269
+ * Space Complexity: O(1) or O(n)
211
270
  */
212
271
  /**
213
272
  * Time Complexity: O(n)
214
- * Space Complexity: O(1)
273
+ * Space Complexity: O(1) or O(n)
215
274
  *
216
275
  * The `deleteAt` function removes an element at a specified position in an array-like data
217
276
  * structure.
@@ -378,8 +437,8 @@ export declare class Deque<E> extends IterableElementBase<E> {
378
437
  * Space Complexity: O(n) - Due to potential resizing.
379
438
  */
380
439
  /**
381
- * Time Complexity: O(1)
382
- * Space Complexity: O(n) - In worst case, resizing doubles the array size.
440
+ * Time Complexity: Amortized O(1) - Similar to push, resizing leads to O(n).
441
+ * Space Complexity: O(n) - Due to potential resizing.
383
442
  *
384
443
  * The addLast function adds an element to the end of an array.
385
444
  * @param {E} element - The element parameter represents the element that you want to add to the end of the
@@ -387,20 +446,25 @@ export declare class Deque<E> extends IterableElementBase<E> {
387
446
  */
388
447
  addLast(element: E): boolean;
389
448
  /**
390
- * Time Complexity: O(1) - Removes the first element.
391
- * Space Complexity: O(1) - In-place operation.
449
+ * Time Complexity: O(1)
450
+ * Space Complexity: O(1)
392
451
  */
393
452
  /**
394
- * Time Complexity: O(1) - Removes the last element.
395
- * Space Complexity: O(1) - Operates in-place.
453
+ * Time Complexity: O(1)
454
+ * Space Complexity: O(1)
396
455
  *
397
456
  * The function "pollLast" removes and returns the last element of an array.
398
457
  * @returns The last element of the array is being returned.
399
458
  */
400
459
  pollLast(): E | undefined;
401
460
  /**
402
- * Time Complexity: O(1).
403
- * Space Complexity: O(n) - Due to potential resizing.
461
+ * Time Complexity: O(1)
462
+ * Space Complexity: O(1)
463
+ * /
464
+
465
+ /**
466
+ * Time Complexity: O(1)
467
+ * Space Complexity: O(1)
404
468
  *
405
469
  * The "addFirst" function adds an element to the beginning of an array.
406
470
  * @param {E} element - The parameter "element" represents the element that you want to add to the
@@ -408,8 +472,13 @@ export declare class Deque<E> extends IterableElementBase<E> {
408
472
  */
409
473
  addFirst(element: E): boolean;
410
474
  /**
411
- * Time Complexity: O(1) - Removes the first element.
412
- * Space Complexity: O(1) - In-place operation.
475
+ * Time Complexity: O(1)
476
+ * Space Complexity: O(1)
477
+ * /
478
+
479
+ /**
480
+ * Time Complexity: O(1)
481
+ * Space Complexity: O(1)
413
482
  *
414
483
  * The function "pollFirst" removes and returns the first element of an array.
415
484
  * @returns The method `pollFirst()` is returning the first element of the array after removing it
@@ -417,6 +486,11 @@ export declare class Deque<E> extends IterableElementBase<E> {
417
486
  */
418
487
  pollFirst(): E | undefined;
419
488
  /**
489
+ * Time Complexity: O(n)
490
+ * Space Complexity: O(1)
491
+ * /
492
+
493
+ /**
420
494
  * Time Complexity: O(n)
421
495
  * Space Complexity: O(1)
422
496
  *
@@ -8,12 +8,6 @@ import { calcMinUnitsRequired, rangeCheck } from '../../utils';
8
8
  * 5. Performance jitter: Deque may experience performance jitter, but DoublyLinkedList will not
9
9
  */
10
10
  export class Deque extends IterableElementBase {
11
- _bucketFirst = 0;
12
- _firstInBucket = 0;
13
- _bucketLast = 0;
14
- _lastInBucket = 0;
15
- _bucketCount = 0;
16
- _bucketSize = 1 << 12;
17
11
  /**
18
12
  * The constructor initializes a Deque object with an optional iterable of elements and options.
19
13
  * @param elements - An iterable object (such as an array or a Set) that contains the initial
@@ -56,6 +50,7 @@ export class Deque extends IterableElementBase {
56
50
  this.push(element);
57
51
  }
58
52
  }
53
+ _bucketSize = 1 << 12;
59
54
  /**
60
55
  * The bucketSize function returns the size of the bucket.
61
56
  *
@@ -64,10 +59,51 @@ export class Deque extends IterableElementBase {
64
59
  get bucketSize() {
65
60
  return this._bucketSize;
66
61
  }
62
+ _bucketFirst = 0;
63
+ /**
64
+ * The function returns the value of the protected variable `_bucketFirst`.
65
+ * @returns The value of the `_bucketFirst` property.
66
+ */
67
+ get bucketFirst() {
68
+ return this._bucketFirst;
69
+ }
70
+ _firstInBucket = 0;
71
+ /**
72
+ * The function returns the value of the protected variable _firstInBucket.
73
+ * @returns The method is returning the value of the variable `_firstInBucket`, which is of type
74
+ * `number`.
75
+ */
76
+ get firstInBucket() {
77
+ return this._firstInBucket;
78
+ }
79
+ _bucketLast = 0;
80
+ /**
81
+ * The function returns the value of the protected variable `_bucketLast`.
82
+ * @returns The value of the `_bucketLast` property, which is a number.
83
+ */
84
+ get bucketLast() {
85
+ return this._bucketLast;
86
+ }
87
+ _lastInBucket = 0;
88
+ /**
89
+ * The function returns the value of the protected variable _lastInBucket.
90
+ * @returns The method is returning the value of the variable `_lastInBucket`, which is of type
91
+ * `number`.
92
+ */
93
+ get lastInBucket() {
94
+ return this._lastInBucket;
95
+ }
96
+ _bucketCount = 0;
97
+ /**
98
+ * The function returns the number of buckets.
99
+ * @returns The number of buckets.
100
+ */
101
+ get bucketCount() {
102
+ return this._bucketCount;
103
+ }
67
104
  _buckets = [];
68
105
  /**
69
106
  * The buckets function returns the buckets property of the object.
70
- *
71
107
  * @return The buckets property
72
108
  */
73
109
  get buckets() {
@@ -233,13 +269,27 @@ export class Deque extends IterableElementBase {
233
269
  return element;
234
270
  }
235
271
  /**
236
- * Time Complexity: O(1) - Removes the last element.
237
- * Space Complexity: O(1) - Operates in-place.
272
+ * Time Complexity: O(1)
273
+ * Space Complexity: O(1)
274
+ */
275
+ /**
276
+ * Time Complexity: O(1)
277
+ * Space Complexity: O(1)
278
+ *
279
+ * The function checks if the size of an object is equal to zero and returns a boolean value.
280
+ * @returns A boolean value indicating whether the size of the object is 0 or not.
238
281
  */
239
282
  isEmpty() {
240
283
  return this.size === 0;
241
284
  }
242
285
  /**
286
+ * Time Complexity: O(1)
287
+ * Space Complexity: O(1)
288
+ */
289
+ /**
290
+ * Time Complexity: O(1)
291
+ * Space Complexity: O(1)
292
+ *
243
293
  * The clear() function resets the state of the object by initializing all variables to their default
244
294
  * values.
245
295
  */
@@ -387,6 +437,25 @@ export class Deque extends IterableElementBase {
387
437
  return newDeque;
388
438
  }
389
439
  }
440
+ /**
441
+ * Time Complexity: O(1)
442
+ * Space Complexity: O(1) or O(n)
443
+ */
444
+ /**
445
+ * Time Complexity: O(1)
446
+ * Space Complexity: O(1) or O(n)
447
+ *
448
+ * The `cutRest` function cuts the elements from a specified position in a deque and returns a new
449
+ * deque with the cut elements.
450
+ * @param {number} pos - The `pos` parameter represents the position from which to cut the Deque. It
451
+ * is a number that indicates the index of the element in the Deque where the cut should start.
452
+ * @param [isCutSelf=false] - isCutSelf is a boolean parameter that determines whether the original
453
+ * Deque should be modified or a new Deque should be created. If isCutSelf is true, the original
454
+ * Deque will be modified by cutting off elements starting from the specified position. If isCutSelf
455
+ * is false, a new De
456
+ * @returns The function `cutRest` returns either the modified original deque (`this`) or a new deque
457
+ * (`newDeque`) depending on the value of the `isCutSelf` parameter.
458
+ */
390
459
  cutRest(pos, isCutSelf = false) {
391
460
  if (isCutSelf) {
392
461
  if (pos < 0) {
@@ -409,11 +478,11 @@ export class Deque extends IterableElementBase {
409
478
  }
410
479
  /**
411
480
  * Time Complexity: O(n)
412
- * Space Complexity: O(1)
481
+ * Space Complexity: O(1) or O(n)
413
482
  */
414
483
  /**
415
484
  * Time Complexity: O(n)
416
- * Space Complexity: O(1)
485
+ * Space Complexity: O(1) or O(n)
417
486
  *
418
487
  * The `deleteAt` function removes an element at a specified position in an array-like data
419
488
  * structure.
@@ -700,8 +769,8 @@ export class Deque extends IterableElementBase {
700
769
  * Space Complexity: O(n) - Due to potential resizing.
701
770
  */
702
771
  /**
703
- * Time Complexity: O(1)
704
- * Space Complexity: O(n) - In worst case, resizing doubles the array size.
772
+ * Time Complexity: Amortized O(1) - Similar to push, resizing leads to O(n).
773
+ * Space Complexity: O(n) - Due to potential resizing.
705
774
  *
706
775
  * The addLast function adds an element to the end of an array.
707
776
  * @param {E} element - The element parameter represents the element that you want to add to the end of the
@@ -711,12 +780,12 @@ export class Deque extends IterableElementBase {
711
780
  return this.push(element);
712
781
  }
713
782
  /**
714
- * Time Complexity: O(1) - Removes the first element.
715
- * Space Complexity: O(1) - In-place operation.
783
+ * Time Complexity: O(1)
784
+ * Space Complexity: O(1)
716
785
  */
717
786
  /**
718
- * Time Complexity: O(1) - Removes the last element.
719
- * Space Complexity: O(1) - Operates in-place.
787
+ * Time Complexity: O(1)
788
+ * Space Complexity: O(1)
720
789
  *
721
790
  * The function "pollLast" removes and returns the last element of an array.
722
791
  * @returns The last element of the array is being returned.
@@ -725,8 +794,13 @@ export class Deque extends IterableElementBase {
725
794
  return this.pop();
726
795
  }
727
796
  /**
728
- * Time Complexity: O(1).
729
- * Space Complexity: O(n) - Due to potential resizing.
797
+ * Time Complexity: O(1)
798
+ * Space Complexity: O(1)
799
+ * /
800
+
801
+ /**
802
+ * Time Complexity: O(1)
803
+ * Space Complexity: O(1)
730
804
  *
731
805
  * The "addFirst" function adds an element to the beginning of an array.
732
806
  * @param {E} element - The parameter "element" represents the element that you want to add to the
@@ -736,8 +810,13 @@ export class Deque extends IterableElementBase {
736
810
  return this.unshift(element);
737
811
  }
738
812
  /**
739
- * Time Complexity: O(1) - Removes the first element.
740
- * Space Complexity: O(1) - In-place operation.
813
+ * Time Complexity: O(1)
814
+ * Space Complexity: O(1)
815
+ * /
816
+
817
+ /**
818
+ * Time Complexity: O(1)
819
+ * Space Complexity: O(1)
741
820
  *
742
821
  * The function "pollFirst" removes and returns the first element of an array.
743
822
  * @returns The method `pollFirst()` is returning the first element of the array after removing it
@@ -747,6 +826,11 @@ export class Deque extends IterableElementBase {
747
826
  return this.shift();
748
827
  }
749
828
  /**
829
+ * Time Complexity: O(n)
830
+ * Space Complexity: O(1)
831
+ * /
832
+
833
+ /**
750
834
  * Time Complexity: O(n)
751
835
  * Space Complexity: O(1)
752
836
  *
@@ -32,7 +32,7 @@ export declare class Queue<E = any> extends IterableElementBase<E> {
32
32
  protected _offset: number;
33
33
  /**
34
34
  * The offset function returns the offset of the current page.
35
- * @return The value of the private variable _offset
35
+ * @return The value of the protected variable _offset
36
36
  */
37
37
  get offset(): number;
38
38
  /**
@@ -41,8 +41,12 @@ export declare class Queue<E = any> extends IterableElementBase<E> {
41
41
  */
42
42
  get size(): number;
43
43
  /**
44
- * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
45
- * Space Complexity: O(1) - no additional space is used.
44
+ * Time Complexity: O(1)
45
+ * Space Complexity: O(1)
46
+ */
47
+ /**
48
+ * Time Complexity: O(1)
49
+ * Space Complexity: O(1)
46
50
  *
47
51
  * The `first` function returns the first element of the array `_elements` if it exists, otherwise it returns `undefined`.
48
52
  * @returns The `get first()` method returns the first element of the data structure, represented by the `_elements` array at
@@ -50,12 +54,12 @@ export declare class Queue<E = any> extends IterableElementBase<E> {
50
54
  */
51
55
  get first(): E | undefined;
52
56
  /**
53
- * Time Complexity: O(1) - constant time as it adds an element to the end of the array.
54
- * Space Complexity: O(1) - no additional space is used.
57
+ * Time Complexity: O(1)
58
+ * Space Complexity: O(1)
55
59
  */
56
60
  /**
57
- * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
58
- * Space Complexity: O(1) - no additional space is used.
61
+ * Time Complexity: O(1)
62
+ * Space Complexity: O(1)
59
63
  *
60
64
  * The `last` function returns the last element in an array-like data structure, or undefined if the structure is empty.
61
65
  * @returns The method `get last()` returns the last element of the `_elements` array if the array is not empty. If the
@@ -63,10 +67,13 @@ export declare class Queue<E = any> extends IterableElementBase<E> {
63
67
  */
64
68
  get last(): E | undefined;
65
69
  /**
66
- * 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.
67
- * Space Complexity: O(1) - no additional space is used.
70
+ * Time Complexity: O(n)
71
+ * Space Complexity: O(n)
68
72
  */
69
73
  /**
74
+ * Time Complexity: O(n)
75
+ * Space Complexity: O(n)
76
+ *
70
77
  * The function "fromArray" creates a new Queue object from an array of elements.Creates a queue from an existing array.
71
78
  * @public
72
79
  * @static
@@ -76,12 +83,12 @@ export declare class Queue<E = any> extends IterableElementBase<E> {
76
83
  */
77
84
  static fromArray<E>(elements: E[]): Queue<E>;
78
85
  /**
79
- * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
80
- * Space Complexity: O(1) - no additional space is used.
86
+ * Time Complexity: O(1)
87
+ * Space Complexity: O(1)
81
88
  */
82
89
  /**
83
- * Time Complexity: O(1) - constant time as it adds an element to the end of the array.
84
- * Space Complexity: O(1) - no additional space is used.
90
+ * Time Complexity: O(1)
91
+ * Space Complexity: O(1)
85
92
  *
86
93
  * 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.
87
94
  * @param {E} element - The `element` parameter represents the element that you want to add to the queue.
@@ -89,12 +96,12 @@ export declare class Queue<E = any> extends IterableElementBase<E> {
89
96
  */
90
97
  push(element: E): boolean;
91
98
  /**
92
- * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
93
- * Space Complexity: O(1) - no additional space is used.
99
+ * Time Complexity: O(1)
100
+ * Space Complexity: O(1)
94
101
  */
95
102
  /**
96
- * 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.
97
- * Space Complexity: O(1) - no additional space is used.
103
+ * Time Complexity: O(1)
104
+ * Space Complexity: O(1)
98
105
  *
99
106
  * The `shift` function removes and returns the first element in the queue, and adjusts the internal data structure if
100
107
  * necessary to optimize performance.
@@ -114,12 +121,12 @@ export declare class Queue<E = any> extends IterableElementBase<E> {
114
121
  */
115
122
  deleteAt(index: number): boolean;
116
123
  /**
117
- * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
118
- * Space Complexity: O(1) - no additional space is used.
124
+ * Time Complexity: O(1)
125
+ * Space Complexity: O(1)
119
126
  */
120
127
  /**
121
- * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
122
- * Space Complexity: O(1) - no additional space is used.
128
+ * Time Complexity: O(1)
129
+ * Space Complexity: O(1)
123
130
  *
124
131
  * The `peek` function returns the first element of the array `_elements` if it exists, otherwise it returns `undefined`.
125
132
  * @returns The `peek()` method returns the first element of the data structure, represented by the `_elements` array at
@@ -127,12 +134,12 @@ export declare class Queue<E = any> extends IterableElementBase<E> {
127
134
  */
128
135
  peek(): E | undefined;
129
136
  /**
130
- * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
131
- * Space Complexity: O(1) - no additional space is used.
137
+ * Time Complexity: O(1)
138
+ * Space Complexity: O(1)
132
139
  */
133
140
  /**
134
- * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
135
- * Space Complexity: O(1) - no additional space is used.
141
+ * Time Complexity: O(1)
142
+ * Space Complexity: O(1)
136
143
  *
137
144
  * The `peekLast` function returns the last element in an array-like data structure, or undefined if the structure is empty.
138
145
  * @returns The method `peekLast()` returns the last element of the `_elements` array if the array is not empty. If the
@@ -140,65 +147,72 @@ export declare class Queue<E = any> extends IterableElementBase<E> {
140
147
  */
141
148
  peekLast(): E | undefined;
142
149
  /**
143
- * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
144
- * Space Complexity: O(1) - no additional space is used.
150
+ * Time Complexity: O(1)
151
+ * Space Complexity: O(1)
145
152
  */
146
153
  /**
147
- * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
148
- * Space Complexity: O(1) - no additional space is used.
154
+ * Time Complexity: O(1)
155
+ * Space Complexity: O(1)
149
156
  *
150
157
  * The enqueue function adds a value to the end of a queue.
151
158
  * @param {E} value - The value parameter represents the value that you want to add to the queue.
152
159
  */
153
160
  enqueue(value: E): boolean;
154
161
  /**
155
- * Time Complexity: O(n) - same as shift().
156
- * Space Complexity: O(1) - same as shift().
162
+ * Time Complexity: O(1)
163
+ * Space Complexity: O(1)
157
164
  */
158
165
  /**
159
- * Time Complexity: O(n) - same as shift().
160
- * Space Complexity: O(1) - same as shift().
166
+ * Time Complexity: O(1)
167
+ * Space Complexity: O(1)
161
168
  *
162
169
  * The `dequeue` function removes and returns the first element from a queue, or returns undefined if the queue is empty.
163
170
  * @returns The method is returning a value of type E or undefined.
164
171
  */
165
172
  dequeue(): E | undefined;
166
173
  /**
167
- * Time Complexity: O(1) - constant time as it retrieves the value at the specified index.
168
- * Space Complexity: O(1) - no additional space is used.
174
+ * Time Complexity: O(1)
175
+ * Space Complexity: O(1)
169
176
  */
170
177
  /**
171
- * Time Complexity: O(1) - constant time as it retrieves the value at the specified index.
172
- * Space Complexity: O(1) - no additional space is used.
178
+ * Time Complexity: O(1)
179
+ * Space Complexity: O(1)
173
180
  *
174
181
  * @param index
175
182
  */
176
183
  at(index: number): E | undefined;
177
184
  /**
178
- * Time Complexity: O(1) - constant time as it retrieves the value at the specified index.
179
- * Space Complexity: O(1) - no additional space is used.
185
+ * Time Complexity: O(1)
186
+ * Space Complexity: O(1)
180
187
  */
181
188
  /**
182
- * Time Complexity: O(1) - constant time as it retrieves the value at the specified index.
183
- * Space Complexity: O(1) - no additional space is used.
189
+ * Time Complexity: O(1)
190
+ * Space Complexity: O(1)
184
191
  *
185
192
  * The function checks if a data structure is empty by comparing its size to zero.
186
193
  * @returns {boolean} A boolean value indicating whether the size of the object is 0 or not.
187
194
  */
188
195
  isEmpty(): boolean;
189
196
  /**
190
- * Time Complexity: O(1) - constant time as it returns a shallow copy of the internal array.
191
- * Space Complexity: O(n) - where n is the number of elements in the queue.
197
+ * Time Complexity: O(1)
198
+ * Space Complexity: O(n)
192
199
  */
193
200
  /**
194
- * Time Complexity: O(1) - constant time as it returns a shallow copy of the internal array.
195
- * Space Complexity: O(n) - where n is the number of elements in the queue.
201
+ * Time Complexity: O(1)
202
+ * Space Complexity: O(n)
196
203
  *
197
204
  * The toArray() function returns an array of elements from the current offset to the end of the _elements array.
198
205
  * @returns An array of type E is being returned.
199
206
  */
200
207
  toArray(): E[];
201
208
  /**
209
+ * Time Complexity: O(1)
210
+ * Space Complexity: O(1)
211
+ */
212
+ /**
213
+ * Time Complexity: O(1)
214
+ * Space Complexity: O(1)
215
+ *
202
216
  * The clear function resets the elements array and offset to their initial values.
203
217
  */
204
218
  clear(): void;
@@ -259,6 +273,12 @@ export declare class Queue<E = any> extends IterableElementBase<E> {
259
273
  * Time Complexity: O(n)
260
274
  * Space Complexity: O(n)
261
275
  */
276
+ /**
277
+ * Time Complexity: O(n)
278
+ * Space Complexity: O(n)
279
+ *
280
+ * The function `_getIterator` returns an iterable iterator for the elements in the class.
281
+ */
262
282
  protected _getIterator(): IterableIterator<E>;
263
283
  }
264
284
  /**