data-structure-typed 1.51.8 → 1.52.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (216) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/README.md +13 -13
  3. package/benchmark/report.html +13 -13
  4. package/benchmark/report.json +152 -152
  5. package/dist/cjs/data-structures/base/index.d.ts +2 -1
  6. package/dist/cjs/data-structures/base/index.js +2 -1
  7. package/dist/cjs/data-structures/base/index.js.map +1 -1
  8. package/dist/cjs/data-structures/base/iterable-element-base.d.ts +171 -0
  9. package/dist/cjs/data-structures/base/iterable-element-base.js +226 -0
  10. package/dist/cjs/data-structures/base/iterable-element-base.js.map +1 -0
  11. package/dist/cjs/data-structures/base/{iterable-base.d.ts → iterable-entry-base.d.ts} +4 -147
  12. package/dist/cjs/data-structures/base/{iterable-base.js → iterable-entry-base.js} +13 -190
  13. package/dist/cjs/data-structures/base/iterable-entry-base.js.map +1 -0
  14. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.d.ts +106 -68
  15. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js +119 -87
  16. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js.map +1 -1
  17. package/dist/cjs/data-structures/binary-tree/avl-tree.d.ts +82 -62
  18. package/dist/cjs/data-structures/binary-tree/avl-tree.js +78 -59
  19. package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +1 -1
  20. package/dist/cjs/data-structures/binary-tree/binary-tree.d.ts +318 -226
  21. package/dist/cjs/data-structures/binary-tree/binary-tree.js +475 -363
  22. package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +1 -1
  23. package/dist/cjs/data-structures/binary-tree/bst.d.ts +192 -202
  24. package/dist/cjs/data-structures/binary-tree/bst.js +207 -249
  25. package/dist/cjs/data-structures/binary-tree/bst.js.map +1 -1
  26. package/dist/cjs/data-structures/binary-tree/rb-tree.d.ts +73 -74
  27. package/dist/cjs/data-structures/binary-tree/rb-tree.js +107 -98
  28. package/dist/cjs/data-structures/binary-tree/rb-tree.js.map +1 -1
  29. package/dist/cjs/data-structures/binary-tree/tree-multi-map.d.ts +92 -75
  30. package/dist/cjs/data-structures/binary-tree/tree-multi-map.js +105 -93
  31. package/dist/cjs/data-structures/binary-tree/tree-multi-map.js.map +1 -1
  32. package/dist/cjs/data-structures/graph/abstract-graph.d.ts +10 -15
  33. package/dist/cjs/data-structures/graph/abstract-graph.js +10 -15
  34. package/dist/cjs/data-structures/graph/abstract-graph.js.map +1 -1
  35. package/dist/cjs/data-structures/hash/hash-map.d.ts +33 -40
  36. package/dist/cjs/data-structures/hash/hash-map.js +40 -55
  37. package/dist/cjs/data-structures/hash/hash-map.js.map +1 -1
  38. package/dist/cjs/data-structures/heap/heap.d.ts +43 -114
  39. package/dist/cjs/data-structures/heap/heap.js +59 -127
  40. package/dist/cjs/data-structures/heap/heap.js.map +1 -1
  41. package/dist/cjs/data-structures/heap/max-heap.d.ts +50 -4
  42. package/dist/cjs/data-structures/heap/max-heap.js +76 -10
  43. package/dist/cjs/data-structures/heap/max-heap.js.map +1 -1
  44. package/dist/cjs/data-structures/heap/min-heap.d.ts +51 -5
  45. package/dist/cjs/data-structures/heap/min-heap.js +68 -11
  46. package/dist/cjs/data-structures/heap/min-heap.js.map +1 -1
  47. package/dist/cjs/data-structures/linked-list/doubly-linked-list.d.ts +22 -28
  48. package/dist/cjs/data-structures/linked-list/doubly-linked-list.js +26 -28
  49. package/dist/cjs/data-structures/linked-list/doubly-linked-list.js.map +1 -1
  50. package/dist/cjs/data-structures/linked-list/singly-linked-list.d.ts +22 -25
  51. package/dist/cjs/data-structures/linked-list/singly-linked-list.js +29 -26
  52. package/dist/cjs/data-structures/linked-list/singly-linked-list.js.map +1 -1
  53. package/dist/cjs/data-structures/priority-queue/max-priority-queue.d.ts +50 -4
  54. package/dist/cjs/data-structures/priority-queue/max-priority-queue.js +79 -10
  55. package/dist/cjs/data-structures/priority-queue/max-priority-queue.js.map +1 -1
  56. package/dist/cjs/data-structures/priority-queue/min-priority-queue.d.ts +51 -5
  57. package/dist/cjs/data-structures/priority-queue/min-priority-queue.js +71 -11
  58. package/dist/cjs/data-structures/priority-queue/min-priority-queue.js.map +1 -1
  59. package/dist/cjs/data-structures/priority-queue/priority-queue.d.ts +50 -4
  60. package/dist/cjs/data-structures/priority-queue/priority-queue.js +70 -1
  61. package/dist/cjs/data-structures/priority-queue/priority-queue.js.map +1 -1
  62. package/dist/cjs/data-structures/queue/deque.d.ts +21 -20
  63. package/dist/cjs/data-structures/queue/deque.js +29 -23
  64. package/dist/cjs/data-structures/queue/deque.js.map +1 -1
  65. package/dist/cjs/data-structures/queue/queue.d.ts +8 -28
  66. package/dist/cjs/data-structures/queue/queue.js +15 -31
  67. package/dist/cjs/data-structures/queue/queue.js.map +1 -1
  68. package/dist/cjs/data-structures/stack/stack.d.ts +17 -22
  69. package/dist/cjs/data-structures/stack/stack.js +25 -24
  70. package/dist/cjs/data-structures/stack/stack.js.map +1 -1
  71. package/dist/cjs/data-structures/trie/trie.d.ts +19 -14
  72. package/dist/cjs/data-structures/trie/trie.js +27 -16
  73. package/dist/cjs/data-structures/trie/trie.js.map +1 -1
  74. package/dist/cjs/interfaces/binary-tree.d.ts +7 -7
  75. package/dist/cjs/types/common.d.ts +1 -2
  76. package/dist/cjs/types/data-structures/base/base.d.ts +5 -2
  77. package/dist/cjs/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +3 -4
  78. package/dist/cjs/types/data-structures/binary-tree/avl-tree.d.ts +3 -4
  79. package/dist/cjs/types/data-structures/binary-tree/binary-tree.d.ts +5 -5
  80. package/dist/cjs/types/data-structures/binary-tree/bst.d.ts +4 -5
  81. package/dist/cjs/types/data-structures/binary-tree/rb-tree.d.ts +3 -4
  82. package/dist/cjs/types/data-structures/binary-tree/tree-multi-map.d.ts +3 -4
  83. package/dist/cjs/types/data-structures/heap/heap.d.ts +3 -2
  84. package/dist/cjs/types/data-structures/linked-list/doubly-linked-list.d.ts +2 -1
  85. package/dist/cjs/types/data-structures/linked-list/singly-linked-list.d.ts +2 -1
  86. package/dist/cjs/types/data-structures/priority-queue/priority-queue.d.ts +1 -1
  87. package/dist/cjs/types/data-structures/queue/deque.d.ts +3 -2
  88. package/dist/cjs/types/data-structures/queue/queue.d.ts +2 -1
  89. package/dist/cjs/types/data-structures/stack/stack.d.ts +2 -1
  90. package/dist/cjs/types/data-structures/trie/trie.d.ts +3 -2
  91. package/dist/cjs/utils/utils.js +3 -5
  92. package/dist/cjs/utils/utils.js.map +1 -1
  93. package/dist/mjs/data-structures/base/index.d.ts +2 -1
  94. package/dist/mjs/data-structures/base/index.js +2 -1
  95. package/dist/mjs/data-structures/base/iterable-element-base.d.ts +171 -0
  96. package/dist/mjs/data-structures/base/iterable-element-base.js +222 -0
  97. package/dist/mjs/data-structures/base/{iterable-base.d.ts → iterable-entry-base.d.ts} +4 -147
  98. package/dist/mjs/data-structures/base/{iterable-base.js → iterable-entry-base.js} +10 -186
  99. package/dist/mjs/data-structures/binary-tree/avl-tree-multi-map.d.ts +106 -68
  100. package/dist/mjs/data-structures/binary-tree/avl-tree-multi-map.js +119 -87
  101. package/dist/mjs/data-structures/binary-tree/avl-tree.d.ts +82 -62
  102. package/dist/mjs/data-structures/binary-tree/avl-tree.js +78 -59
  103. package/dist/mjs/data-structures/binary-tree/binary-tree.d.ts +318 -226
  104. package/dist/mjs/data-structures/binary-tree/binary-tree.js +476 -364
  105. package/dist/mjs/data-structures/binary-tree/bst.d.ts +192 -202
  106. package/dist/mjs/data-structures/binary-tree/bst.js +211 -255
  107. package/dist/mjs/data-structures/binary-tree/rb-tree.d.ts +73 -74
  108. package/dist/mjs/data-structures/binary-tree/rb-tree.js +107 -98
  109. package/dist/mjs/data-structures/binary-tree/tree-multi-map.d.ts +92 -75
  110. package/dist/mjs/data-structures/binary-tree/tree-multi-map.js +105 -93
  111. package/dist/mjs/data-structures/graph/abstract-graph.d.ts +10 -15
  112. package/dist/mjs/data-structures/graph/abstract-graph.js +10 -15
  113. package/dist/mjs/data-structures/hash/hash-map.d.ts +33 -40
  114. package/dist/mjs/data-structures/hash/hash-map.js +41 -55
  115. package/dist/mjs/data-structures/heap/heap.d.ts +43 -114
  116. package/dist/mjs/data-structures/heap/heap.js +60 -128
  117. package/dist/mjs/data-structures/heap/max-heap.d.ts +50 -4
  118. package/dist/mjs/data-structures/heap/max-heap.js +79 -10
  119. package/dist/mjs/data-structures/heap/min-heap.d.ts +51 -5
  120. package/dist/mjs/data-structures/heap/min-heap.js +68 -11
  121. package/dist/mjs/data-structures/linked-list/doubly-linked-list.d.ts +22 -28
  122. package/dist/mjs/data-structures/linked-list/doubly-linked-list.js +26 -28
  123. package/dist/mjs/data-structures/linked-list/singly-linked-list.d.ts +22 -25
  124. package/dist/mjs/data-structures/linked-list/singly-linked-list.js +29 -26
  125. package/dist/mjs/data-structures/priority-queue/max-priority-queue.d.ts +50 -4
  126. package/dist/mjs/data-structures/priority-queue/max-priority-queue.js +82 -10
  127. package/dist/mjs/data-structures/priority-queue/min-priority-queue.d.ts +51 -5
  128. package/dist/mjs/data-structures/priority-queue/min-priority-queue.js +71 -11
  129. package/dist/mjs/data-structures/priority-queue/priority-queue.d.ts +50 -4
  130. package/dist/mjs/data-structures/priority-queue/priority-queue.js +70 -1
  131. package/dist/mjs/data-structures/queue/deque.d.ts +21 -20
  132. package/dist/mjs/data-structures/queue/deque.js +29 -23
  133. package/dist/mjs/data-structures/queue/queue.d.ts +8 -28
  134. package/dist/mjs/data-structures/queue/queue.js +15 -31
  135. package/dist/mjs/data-structures/stack/stack.d.ts +17 -22
  136. package/dist/mjs/data-structures/stack/stack.js +25 -24
  137. package/dist/mjs/data-structures/trie/trie.d.ts +19 -14
  138. package/dist/mjs/data-structures/trie/trie.js +27 -16
  139. package/dist/mjs/interfaces/binary-tree.d.ts +7 -7
  140. package/dist/mjs/types/common.d.ts +1 -2
  141. package/dist/mjs/types/data-structures/base/base.d.ts +5 -2
  142. package/dist/mjs/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +3 -4
  143. package/dist/mjs/types/data-structures/binary-tree/avl-tree.d.ts +3 -4
  144. package/dist/mjs/types/data-structures/binary-tree/binary-tree.d.ts +5 -5
  145. package/dist/mjs/types/data-structures/binary-tree/bst.d.ts +4 -5
  146. package/dist/mjs/types/data-structures/binary-tree/rb-tree.d.ts +3 -4
  147. package/dist/mjs/types/data-structures/binary-tree/tree-multi-map.d.ts +3 -4
  148. package/dist/mjs/types/data-structures/heap/heap.d.ts +3 -2
  149. package/dist/mjs/types/data-structures/linked-list/doubly-linked-list.d.ts +2 -1
  150. package/dist/mjs/types/data-structures/linked-list/singly-linked-list.d.ts +2 -1
  151. package/dist/mjs/types/data-structures/priority-queue/priority-queue.d.ts +1 -1
  152. package/dist/mjs/types/data-structures/queue/deque.d.ts +3 -2
  153. package/dist/mjs/types/data-structures/queue/queue.d.ts +2 -1
  154. package/dist/mjs/types/data-structures/stack/stack.d.ts +2 -1
  155. package/dist/mjs/types/data-structures/trie/trie.d.ts +3 -2
  156. package/dist/mjs/utils/utils.js +3 -5
  157. package/dist/umd/data-structure-typed.js +1949 -1481
  158. package/dist/umd/data-structure-typed.min.js +2 -2
  159. package/dist/umd/data-structure-typed.min.js.map +1 -1
  160. package/package.json +6 -6
  161. package/src/data-structures/base/index.ts +2 -1
  162. package/src/data-structures/base/iterable-element-base.ts +250 -0
  163. package/src/data-structures/base/{iterable-base.ts → iterable-entry-base.ts} +22 -213
  164. package/src/data-structures/binary-tree/avl-tree-multi-map.ts +144 -95
  165. package/src/data-structures/binary-tree/avl-tree.ts +96 -69
  166. package/src/data-structures/binary-tree/binary-tree.ts +535 -403
  167. package/src/data-structures/binary-tree/bst.ts +247 -277
  168. package/src/data-structures/binary-tree/rb-tree.ts +123 -103
  169. package/src/data-structures/binary-tree/tree-multi-map.ts +127 -102
  170. package/src/data-structures/graph/abstract-graph.ts +10 -10
  171. package/src/data-structures/hash/hash-map.ts +46 -53
  172. package/src/data-structures/heap/heap.ts +71 -152
  173. package/src/data-structures/heap/max-heap.ts +88 -13
  174. package/src/data-structures/heap/min-heap.ts +78 -15
  175. package/src/data-structures/linked-list/doubly-linked-list.ts +32 -32
  176. package/src/data-structures/linked-list/singly-linked-list.ts +37 -29
  177. package/src/data-structures/priority-queue/max-priority-queue.ts +94 -13
  178. package/src/data-structures/priority-queue/min-priority-queue.ts +84 -15
  179. package/src/data-structures/priority-queue/priority-queue.ts +81 -4
  180. package/src/data-structures/queue/deque.ts +37 -26
  181. package/src/data-structures/queue/queue.ts +23 -36
  182. package/src/data-structures/stack/stack.ts +31 -26
  183. package/src/data-structures/trie/trie.ts +35 -20
  184. package/src/interfaces/binary-tree.ts +9 -9
  185. package/src/types/common.ts +1 -2
  186. package/src/types/data-structures/base/base.ts +14 -6
  187. package/src/types/data-structures/binary-tree/avl-tree-multi-map.ts +3 -4
  188. package/src/types/data-structures/binary-tree/avl-tree.ts +3 -4
  189. package/src/types/data-structures/binary-tree/binary-tree.ts +6 -6
  190. package/src/types/data-structures/binary-tree/bst.ts +4 -5
  191. package/src/types/data-structures/binary-tree/rb-tree.ts +3 -4
  192. package/src/types/data-structures/binary-tree/tree-multi-map.ts +3 -4
  193. package/src/types/data-structures/heap/heap.ts +4 -1
  194. package/src/types/data-structures/linked-list/doubly-linked-list.ts +3 -1
  195. package/src/types/data-structures/linked-list/singly-linked-list.ts +3 -1
  196. package/src/types/data-structures/priority-queue/priority-queue.ts +1 -1
  197. package/src/types/data-structures/queue/deque.ts +3 -1
  198. package/src/types/data-structures/queue/queue.ts +3 -1
  199. package/src/types/data-structures/stack/stack.ts +3 -1
  200. package/src/types/data-structures/trie/trie.ts +3 -1
  201. package/src/utils/utils.ts +3 -3
  202. package/test/integration/avl-tree.test.ts +2 -2
  203. package/test/integration/bst.test.ts +3 -3
  204. package/test/integration/index.html +25 -11
  205. package/test/unit/data-structures/binary-tree/avl-tree-multi-map.test.ts +68 -0
  206. package/test/unit/data-structures/binary-tree/binary-tree.test.ts +56 -0
  207. package/test/unit/data-structures/graph/directed-graph.test.ts +2 -2
  208. package/test/unit/data-structures/heap/heap.test.ts +80 -0
  209. package/test/unit/data-structures/heap/max-heap.test.ts +44 -1
  210. package/test/unit/data-structures/heap/min-heap.test.ts +18 -1
  211. package/test/unit/data-structures/priority-queue/max-priority-queue.test.ts +42 -0
  212. package/test/unit/data-structures/queue/deque.test.ts +30 -0
  213. package/test/unit/data-structures/queue/queue.test.ts +56 -0
  214. package/test/utils/big-o.ts +12 -6
  215. package/tsconfig-base.json +1 -0
  216. package/dist/cjs/data-structures/base/iterable-base.js.map +0 -1
@@ -5,9 +5,9 @@
5
5
  * @copyright Copyright (c) 2022 Kirk Qi <qilinaus@gmail.com>
6
6
  * @license MIT License
7
7
  */
8
- import type { PriorityQueueOptions } from '../../types';
8
+ import type { Comparator, ElementCallback, PriorityQueueOptions } from '../../types';
9
9
  import { PriorityQueue } from './priority-queue';
10
- export declare class MinPriorityQueue<E = any> extends PriorityQueue<E> {
10
+ export declare class MinPriorityQueue<E = any, R = any> extends PriorityQueue<E, R> {
11
11
  /**
12
12
  * The constructor initializes a PriorityQueue with optional elements and options, including a
13
13
  * comparator function.
@@ -15,9 +15,55 @@ export declare class MinPriorityQueue<E = any> extends PriorityQueue<E> {
15
15
  * elements to be added to the priority queue. It is optional and defaults to an empty array if not
16
16
  * provided.
17
17
  * @param options - The `options` parameter is an object that contains additional configuration
18
- * options for the priority queue. In this case, it has a property called `comparator` which is a
18
+ * options for the priority queue. In this case, it has a property called `comparator,` which is a
19
19
  * function used to compare elements in the priority queue. The `comparator` function takes two
20
- * parameters `a` and `b`,
20
+ * parameters `a` and `b`
21
21
  */
22
- constructor(elements?: Iterable<E>, options?: PriorityQueueOptions<E>);
22
+ constructor(elements?: Iterable<E> | Iterable<R>, options?: PriorityQueueOptions<E, R>);
23
+ /**
24
+ * The `clone` function returns a new instance of the `MinPriorityQueue` class with the same
25
+ * comparator and toElementFn as the original instance.
26
+ * @returns The method is returning a new instance of the `MinPriorityQueue` class with the same
27
+ * properties as the current instance.
28
+ */
29
+ clone(): MinPriorityQueue<E, R>;
30
+ /**
31
+ * Time Complexity: O(n)
32
+ * Space Complexity: O(n)
33
+ *
34
+ * The `filter` function creates a new MinPriorityQueue object containing elements that pass a given callback
35
+ * function.
36
+ * @param callback - The `callback` parameter is a function that will be called for each element in
37
+ * the heap. It takes three arguments: the current element, the index of the current element, and the
38
+ * heap itself. The callback function should return a boolean value indicating whether the current
39
+ * element should be included in the filtered list
40
+ * @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
41
+ * to be used as `this` when executing the `callback` function. If `thisArg` is provided, it will be
42
+ * passed as the `this` value to the `callback` function. If `thisArg` is
43
+ * @returns The `filter` method is returning a new `MinPriorityQueue` object that contains the elements that pass
44
+ * the filter condition specified by the `callback` function.
45
+ */
46
+ filter(callback: ElementCallback<E, R, boolean, MinPriorityQueue<E, R>>, thisArg?: any): MinPriorityQueue<E, R>;
47
+ /**
48
+ * Time Complexity: O(n log n)
49
+ * Space Complexity: O(n)
50
+ *
51
+ * The `map` function creates a new heap by applying a callback function to each element of the
52
+ * original heap.
53
+ * @param callback - The `callback` parameter is a function that will be called for each element in
54
+ * the heap. It takes three arguments: `el` (the current element), `index` (the index of the current
55
+ * element), and `this` (the heap itself). The callback function should return a value of
56
+ * @param comparator - The `comparator` parameter is a function that defines the order of the
57
+ * elements in the heap. It takes two elements `a` and `b` as arguments and returns a negative number
58
+ * if `a` should be placed before `b`, a positive number if `a` should be placed after
59
+ * @param [toElementFn] - The `toElementFn` parameter is an optional function that converts the raw
60
+ * element `RR` to the desired type `T`. It takes a single argument `rawElement` of type `RR` and
61
+ * returns a value of type `T`. This function is used to transform the elements of the original
62
+ * @param {any} [thisArg] - The `thisArg` parameter is an optional argument that allows you to
63
+ * specify the value of `this` within the callback function. It is used to set the context or scope
64
+ * in which the callback function will be executed. If `thisArg` is provided, it will be used as the
65
+ * value of
66
+ * @returns a new instance of the `MinPriorityQueue` class with the mapped elements.
67
+ */
68
+ map<EM, RM>(callback: ElementCallback<E, R, EM, MinPriorityQueue<E, R>>, comparator: Comparator<EM>, toElementFn?: (rawElement: RM) => EM, thisArg?: any): MinPriorityQueue<EM, RM>;
23
69
  }
@@ -7,20 +7,80 @@ export class MinPriorityQueue extends PriorityQueue {
7
7
  * elements to be added to the priority queue. It is optional and defaults to an empty array if not
8
8
  * provided.
9
9
  * @param options - The `options` parameter is an object that contains additional configuration
10
- * options for the priority queue. In this case, it has a property called `comparator` which is a
10
+ * options for the priority queue. In this case, it has a property called `comparator,` which is a
11
11
  * function used to compare elements in the priority queue. The `comparator` function takes two
12
- * parameters `a` and `b`,
12
+ * parameters `a` and `b`
13
13
  */
14
- constructor(elements = [], options = {
15
- comparator: (a, b) => {
16
- if (!(typeof a === 'number' && typeof b === 'number')) {
17
- throw new Error('The a, b params of compare function must be number');
18
- }
19
- else {
20
- return a - b;
14
+ constructor(elements = [], options) {
15
+ super(elements, options);
16
+ }
17
+ /**
18
+ * The `clone` function returns a new instance of the `MinPriorityQueue` class with the same
19
+ * comparator and toElementFn as the original instance.
20
+ * @returns The method is returning a new instance of the `MinPriorityQueue` class with the same
21
+ * properties as the current instance.
22
+ */
23
+ clone() {
24
+ return new MinPriorityQueue(this, { comparator: this.comparator, toElementFn: this.toElementFn });
25
+ }
26
+ /**
27
+ * Time Complexity: O(n)
28
+ * Space Complexity: O(n)
29
+ *
30
+ * The `filter` function creates a new MinPriorityQueue object containing elements that pass a given callback
31
+ * function.
32
+ * @param callback - The `callback` parameter is a function that will be called for each element in
33
+ * the heap. It takes three arguments: the current element, the index of the current element, and the
34
+ * heap itself. The callback function should return a boolean value indicating whether the current
35
+ * element should be included in the filtered list
36
+ * @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
37
+ * to be used as `this` when executing the `callback` function. If `thisArg` is provided, it will be
38
+ * passed as the `this` value to the `callback` function. If `thisArg` is
39
+ * @returns The `filter` method is returning a new `MinPriorityQueue` object that contains the elements that pass
40
+ * the filter condition specified by the `callback` function.
41
+ */
42
+ filter(callback, thisArg) {
43
+ const filteredPriorityQueue = new MinPriorityQueue([], {
44
+ toElementFn: this.toElementFn,
45
+ comparator: this.comparator
46
+ });
47
+ let index = 0;
48
+ for (const current of this) {
49
+ if (callback.call(thisArg, current, index, this)) {
50
+ filteredPriorityQueue.add(current);
21
51
  }
52
+ index++;
22
53
  }
23
- }) {
24
- super(elements, options);
54
+ return filteredPriorityQueue;
55
+ }
56
+ /**
57
+ * Time Complexity: O(n log n)
58
+ * Space Complexity: O(n)
59
+ *
60
+ * The `map` function creates a new heap by applying a callback function to each element of the
61
+ * original heap.
62
+ * @param callback - The `callback` parameter is a function that will be called for each element in
63
+ * the heap. It takes three arguments: `el` (the current element), `index` (the index of the current
64
+ * element), and `this` (the heap itself). The callback function should return a value of
65
+ * @param comparator - The `comparator` parameter is a function that defines the order of the
66
+ * elements in the heap. It takes two elements `a` and `b` as arguments and returns a negative number
67
+ * if `a` should be placed before `b`, a positive number if `a` should be placed after
68
+ * @param [toElementFn] - The `toElementFn` parameter is an optional function that converts the raw
69
+ * element `RR` to the desired type `T`. It takes a single argument `rawElement` of type `RR` and
70
+ * returns a value of type `T`. This function is used to transform the elements of the original
71
+ * @param {any} [thisArg] - The `thisArg` parameter is an optional argument that allows you to
72
+ * specify the value of `this` within the callback function. It is used to set the context or scope
73
+ * in which the callback function will be executed. If `thisArg` is provided, it will be used as the
74
+ * value of
75
+ * @returns a new instance of the `MinPriorityQueue` class with the mapped elements.
76
+ */
77
+ map(callback, comparator, toElementFn, thisArg) {
78
+ const mappedPriorityQueue = new MinPriorityQueue([], { comparator, toElementFn });
79
+ let index = 0;
80
+ for (const el of this) {
81
+ mappedPriorityQueue.add(callback.call(thisArg, el, index, this));
82
+ index++;
83
+ }
84
+ return mappedPriorityQueue;
25
85
  }
26
86
  }
@@ -5,7 +5,7 @@
5
5
  * @copyright Copyright (c) 2022 Kirk Qi <qilinaus@gmail.com>
6
6
  * @license MIT License
7
7
  */
8
- import type { PriorityQueueOptions } from '../../types';
8
+ import type { Comparator, ElementCallback, PriorityQueueOptions } from '../../types';
9
9
  import { Heap } from '../heap';
10
10
  /**
11
11
  * 1. Element Priority: In a PriorityQueue, elements are sorted according to their priority. Each dequeue (element removal) operation removes the element with the highest priority. The priority can be determined based on the natural ordering of the elements or through a provided comparator (Comparator).
@@ -15,14 +15,60 @@ import { Heap } from '../heap';
15
15
  * 5. Huffman Coding: Used to select the smallest node combination when constructing a Huffman tree.
16
16
  * 6. Kth Largest Element in a Data Stream: Used to maintain a min-heap of size K for quickly finding the Kth largest element in stream data
17
17
  */
18
- export declare class PriorityQueue<E = any> extends Heap<E> {
18
+ export declare class PriorityQueue<E = any, R = any> extends Heap<E, R> {
19
19
  /**
20
20
  * The constructor initializes a priority queue with optional elements and options.
21
21
  * @param elements - The `elements` parameter is an iterable object that contains the initial
22
- * elements to be added to the priority queue. It is an optional parameter and if not provided, the
22
+ * elements to be added to the priority queue. It is an optional parameter, and if not provided, the
23
23
  * priority queue will be initialized as empty.
24
24
  * @param [options] - The `options` parameter is an optional object that can be used to customize the
25
25
  * behavior of the priority queue. It can contain the following properties:
26
26
  */
27
- constructor(elements?: Iterable<E>, options?: PriorityQueueOptions<E>);
27
+ constructor(elements?: Iterable<E> | Iterable<R>, options?: PriorityQueueOptions<E, R>);
28
+ /**
29
+ * The `clone` function returns a new instance of the `PriorityQueue` class with the same comparator
30
+ * and toElementFn as the original instance.
31
+ * @returns The method is returning a new instance of the `PriorityQueue` class with the same
32
+ * elements and properties as the current instance.
33
+ */
34
+ clone(): PriorityQueue<E, R>;
35
+ /**
36
+ * Time Complexity: O(n)
37
+ * Space Complexity: O(n)
38
+ *
39
+ * The `filter` function creates a new PriorityQueue object containing elements that pass a given callback
40
+ * function.
41
+ * @param callback - The `callback` parameter is a function that will be called for each element in
42
+ * the heap. It takes three arguments: the current element, the index of the current element, and the
43
+ * heap itself. The callback function should return a boolean value indicating whether the current
44
+ * element should be included in the filtered list
45
+ * @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
46
+ * to be used as `this` when executing the `callback` function. If `thisArg` is provided, it will be
47
+ * passed as the `this` value to the `callback` function. If `thisArg` is
48
+ * @returns The `filter` method is returning a new `PriorityQueue` object that contains the elements that pass
49
+ * the filter condition specified by the `callback` function.
50
+ */
51
+ filter(callback: ElementCallback<E, R, boolean, PriorityQueue<E, R>>, thisArg?: any): PriorityQueue<E, R>;
52
+ /**
53
+ * Time Complexity: O(n log n)
54
+ * Space Complexity: O(n)
55
+ *
56
+ * The `map` function creates a new heap by applying a callback function to each element of the
57
+ * original heap.
58
+ * @param callback - The `callback` parameter is a function that will be called for each element in
59
+ * the heap. It takes three arguments: `el` (the current element), `index` (the index of the current
60
+ * element), and `this` (the heap itself). The callback function should return a value of
61
+ * @param comparator - The `comparator` parameter is a function that defines the order of the
62
+ * elements in the heap. It takes two elements `a` and `b` as arguments and returns a negative number
63
+ * if `a` should be placed before `b`, a positive number if `a` should be placed after
64
+ * @param [toElementFn] - The `toElementFn` parameter is an optional function that converts the raw
65
+ * element `RR` to the desired type `T`. It takes a single argument `rawElement` of type `RR` and
66
+ * returns a value of type `T`. This function is used to transform the elements of the original
67
+ * @param {any} [thisArg] - The `thisArg` parameter is an optional argument that allows you to
68
+ * specify the value of `this` within the callback function. It is used to set the context or scope
69
+ * in which the callback function will be executed. If `thisArg` is provided, it will be used as the
70
+ * value of
71
+ * @returns a new instance of the `PriorityQueue` class with the mapped elements.
72
+ */
73
+ map<EM, RM>(callback: ElementCallback<E, R, EM, PriorityQueue<E, R>>, comparator: Comparator<EM>, toElementFn?: (rawElement: RM) => EM, thisArg?: any): PriorityQueue<EM, RM>;
28
74
  }
@@ -11,7 +11,7 @@ export class PriorityQueue extends Heap {
11
11
  /**
12
12
  * The constructor initializes a priority queue with optional elements and options.
13
13
  * @param elements - The `elements` parameter is an iterable object that contains the initial
14
- * elements to be added to the priority queue. It is an optional parameter and if not provided, the
14
+ * elements to be added to the priority queue. It is an optional parameter, and if not provided, the
15
15
  * priority queue will be initialized as empty.
16
16
  * @param [options] - The `options` parameter is an optional object that can be used to customize the
17
17
  * behavior of the priority queue. It can contain the following properties:
@@ -19,4 +19,73 @@ export class PriorityQueue extends Heap {
19
19
  constructor(elements = [], options) {
20
20
  super(elements, options);
21
21
  }
22
+ /**
23
+ * The `clone` function returns a new instance of the `PriorityQueue` class with the same comparator
24
+ * and toElementFn as the original instance.
25
+ * @returns The method is returning a new instance of the `PriorityQueue` class with the same
26
+ * elements and properties as the current instance.
27
+ */
28
+ clone() {
29
+ return new PriorityQueue(this, { comparator: this.comparator, toElementFn: this.toElementFn });
30
+ }
31
+ /**
32
+ * Time Complexity: O(n)
33
+ * Space Complexity: O(n)
34
+ *
35
+ * The `filter` function creates a new PriorityQueue object containing elements that pass a given callback
36
+ * function.
37
+ * @param callback - The `callback` parameter is a function that will be called for each element in
38
+ * the heap. It takes three arguments: the current element, the index of the current element, and the
39
+ * heap itself. The callback function should return a boolean value indicating whether the current
40
+ * element should be included in the filtered list
41
+ * @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
42
+ * to be used as `this` when executing the `callback` function. If `thisArg` is provided, it will be
43
+ * passed as the `this` value to the `callback` function. If `thisArg` is
44
+ * @returns The `filter` method is returning a new `PriorityQueue` object that contains the elements that pass
45
+ * the filter condition specified by the `callback` function.
46
+ */
47
+ filter(callback, thisArg) {
48
+ const filteredPriorityQueue = new PriorityQueue([], {
49
+ toElementFn: this.toElementFn,
50
+ comparator: this.comparator
51
+ });
52
+ let index = 0;
53
+ for (const current of this) {
54
+ if (callback.call(thisArg, current, index, this)) {
55
+ filteredPriorityQueue.add(current);
56
+ }
57
+ index++;
58
+ }
59
+ return filteredPriorityQueue;
60
+ }
61
+ /**
62
+ * Time Complexity: O(n log n)
63
+ * Space Complexity: O(n)
64
+ *
65
+ * The `map` function creates a new heap by applying a callback function to each element of the
66
+ * original heap.
67
+ * @param callback - The `callback` parameter is a function that will be called for each element in
68
+ * the heap. It takes three arguments: `el` (the current element), `index` (the index of the current
69
+ * element), and `this` (the heap itself). The callback function should return a value of
70
+ * @param comparator - The `comparator` parameter is a function that defines the order of the
71
+ * elements in the heap. It takes two elements `a` and `b` as arguments and returns a negative number
72
+ * if `a` should be placed before `b`, a positive number if `a` should be placed after
73
+ * @param [toElementFn] - The `toElementFn` parameter is an optional function that converts the raw
74
+ * element `RR` to the desired type `T`. It takes a single argument `rawElement` of type `RR` and
75
+ * returns a value of type `T`. This function is used to transform the elements of the original
76
+ * @param {any} [thisArg] - The `thisArg` parameter is an optional argument that allows you to
77
+ * specify the value of `this` within the callback function. It is used to set the context or scope
78
+ * in which the callback function will be executed. If `thisArg` is provided, it will be used as the
79
+ * value of
80
+ * @returns a new instance of the `PriorityQueue` class with the mapped elements.
81
+ */
82
+ map(callback, comparator, toElementFn, thisArg) {
83
+ const mappedPriorityQueue = new PriorityQueue([], { comparator, toElementFn });
84
+ let index = 0;
85
+ for (const el of this) {
86
+ mappedPriorityQueue.add(callback.call(thisArg, el, index, this));
87
+ index++;
88
+ }
89
+ return mappedPriorityQueue;
90
+ }
22
91
  }
@@ -14,9 +14,9 @@ import { IterableElementBase } from '../base';
14
14
  * 4. Efficiency: Adding and removing elements at both ends of a deque is usually very fast. However, when the dynamic array needs to expand, it may involve copying the entire array to a larger one, and this operation has a time complexity of O(n).
15
15
  * 5. Performance jitter: Deque may experience performance jitter, but DoublyLinkedList will not
16
16
  */
17
- export declare class Deque<E> extends IterableElementBase<E> {
17
+ export declare class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E, R>> {
18
18
  /**
19
- * The constructor initializes a Deque object with an optional iterable of elements and options.
19
+ * The constructor initializes a Deque object with optional iterable of elements and options.
20
20
  * @param elements - An iterable object (such as an array or a Set) that contains the initial
21
21
  * elements to be added to the deque. It can also be an object with a `length` or `size` property
22
22
  * that represents the number of elements in the iterable object. If no elements are provided, an
@@ -26,7 +26,7 @@ export declare class Deque<E> extends IterableElementBase<E> {
26
26
  * which determines the size of each bucket in the deque. If the `bucketSize` option is not provided
27
27
  * or is not a number
28
28
  */
29
- constructor(elements?: IterableWithSizeOrLength<E>, options?: DequeOptions);
29
+ constructor(elements?: IterableWithSizeOrLength<E> | IterableWithSizeOrLength<R>, options?: DequeOptions<E, R>);
30
30
  protected _bucketSize: number;
31
31
  /**
32
32
  * The bucketSize function returns the size of the bucket.
@@ -392,7 +392,7 @@ export declare class Deque<E> extends IterableElementBase<E> {
392
392
  * @returns The `clone()` method is returning a new instance of the `Deque` class with the same
393
393
  * elements as the original deque (`this`) and the same bucket size.
394
394
  */
395
- clone(): Deque<E>;
395
+ clone(): Deque<E, R>;
396
396
  /**
397
397
  * Time Complexity: O(n)
398
398
  * Space Complexity: O(n)
@@ -413,31 +413,32 @@ export declare class Deque<E> extends IterableElementBase<E> {
413
413
  * @returns The `filter` method is returning a new `Deque` object that contains the elements that
414
414
  * satisfy the given predicate function.
415
415
  */
416
- filter(predicate: ElementCallback<E, boolean>, thisArg?: any): Deque<E>;
416
+ filter(predicate: ElementCallback<E, R, boolean, Deque<E, R>>, thisArg?: any): Deque<E, R>;
417
417
  /**
418
418
  * Time Complexity: O(n)
419
419
  * Space Complexity: O(n)
420
420
  */
421
421
  /**
422
- * Time Complexity: O(n)
423
- * Space Complexity: O(n)
424
- *
425
- * The `map` function creates a new Deque by applying a callback function to each element of the
426
- * original Deque.
427
- * @param callback - The `callback` parameter is a function that will be called for each element in
428
- * the deque. It takes three arguments:
429
- * @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
430
- * to be used as `this` when executing the `callback` function. If `thisArg` is provided, it will be
431
- * passed as the `this` value to the `callback` function. If `thisArg` is
432
- * @returns a new Deque object with the mapped values.
422
+ * The `map` function takes a callback function and applies it to each element in the deque,
423
+ * returning a new deque with the results.
424
+ * @param callback - The callback parameter is a function that will be called for each element in the
425
+ * deque. It takes three arguments: the current element, the index of the element, and the deque
426
+ * itself. It should return a value of type EM.
427
+ * @param [toElementFn] - The `toElementFn` parameter is an optional function that can be used to
428
+ * transform the raw element (`RM`) into a new element (`EM`) before adding it to the new deque. If
429
+ * provided, this function will be called for each raw element in the original deque.
430
+ * @param {any} [thisArg] - The `thisArg` parameter is an optional argument that allows you to
431
+ * specify the value of `this` within the callback function. It is used to set the context or scope
432
+ * in which the callback function will be executed. If `thisArg` is provided, it will be used as the
433
+ * value of
434
+ * @returns a new Deque object with elements of type EM and raw elements of type RM.
433
435
  */
434
- map<T>(callback: ElementCallback<E, T>, thisArg?: any): Deque<T>;
436
+ map<EM, RM>(callback: ElementCallback<E, R, EM, Deque<E, R>>, toElementFn?: (rawElement: RM) => EM, thisArg?: any): Deque<EM, RM>;
435
437
  /**
436
438
  * Time Complexity: O(n)
437
439
  * Space Complexity: O(1)
438
- * /
439
-
440
- /**
440
+ */
441
+ /**
441
442
  * Time Complexity: O(n)
442
443
  * Space Complexity: O(1)
443
444
  *
@@ -9,7 +9,7 @@ import { calcMinUnitsRequired, rangeCheck } from '../../utils';
9
9
  */
10
10
  export class Deque extends IterableElementBase {
11
11
  /**
12
- * The constructor initializes a Deque object with an optional iterable of elements and options.
12
+ * The constructor initializes a Deque object with optional iterable of elements and options.
13
13
  * @param elements - An iterable object (such as an array or a Set) that contains the initial
14
14
  * elements to be added to the deque. It can also be an object with a `length` or `size` property
15
15
  * that represents the number of elements in the iterable object. If no elements are provided, an
@@ -20,7 +20,7 @@ export class Deque extends IterableElementBase {
20
20
  * or is not a number
21
21
  */
22
22
  constructor(elements = [], options) {
23
- super();
23
+ super(options);
24
24
  if (options) {
25
25
  const { bucketSize } = options;
26
26
  if (typeof bucketSize === 'number')
@@ -46,8 +46,13 @@ export class Deque extends IterableElementBase {
46
46
  const needBucketNum = calcMinUnitsRequired(_size, this._bucketSize);
47
47
  this._bucketFirst = this._bucketLast = (this._bucketCount >> 1) - (needBucketNum >> 1);
48
48
  this._firstInBucket = this._lastInBucket = (this._bucketSize - (_size % this._bucketSize)) >> 1;
49
- for (const element of elements) {
50
- this.push(element);
49
+ for (const el of elements) {
50
+ if (this.toElementFn) {
51
+ this.push(this.toElementFn(el));
52
+ }
53
+ else {
54
+ this.push(el);
55
+ }
51
56
  }
52
57
  }
53
58
  _bucketSize = 1 << 12;
@@ -705,7 +710,7 @@ export class Deque extends IterableElementBase {
705
710
  * elements as the original deque (`this`) and the same bucket size.
706
711
  */
707
712
  clone() {
708
- return new Deque([...this], { bucketSize: this.bucketSize });
713
+ return new Deque(this, { bucketSize: this.bucketSize, toElementFn: this.toElementFn });
709
714
  }
710
715
  /**
711
716
  * Time Complexity: O(n)
@@ -728,7 +733,7 @@ export class Deque extends IterableElementBase {
728
733
  * satisfy the given predicate function.
729
734
  */
730
735
  filter(predicate, thisArg) {
731
- const newDeque = new Deque([], { bucketSize: this._bucketSize });
736
+ const newDeque = new Deque([], { bucketSize: this._bucketSize, toElementFn: this.toElementFn });
732
737
  let index = 0;
733
738
  for (const el of this) {
734
739
  if (predicate.call(thisArg, el, index, this)) {
@@ -743,20 +748,22 @@ export class Deque extends IterableElementBase {
743
748
  * Space Complexity: O(n)
744
749
  */
745
750
  /**
746
- * Time Complexity: O(n)
747
- * Space Complexity: O(n)
748
- *
749
- * The `map` function creates a new Deque by applying a callback function to each element of the
750
- * original Deque.
751
- * @param callback - The `callback` parameter is a function that will be called for each element in
752
- * the deque. It takes three arguments:
753
- * @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
754
- * to be used as `this` when executing the `callback` function. If `thisArg` is provided, it will be
755
- * passed as the `this` value to the `callback` function. If `thisArg` is
756
- * @returns a new Deque object with the mapped values.
757
- */
758
- map(callback, thisArg) {
759
- const newDeque = new Deque([], { bucketSize: this._bucketSize });
751
+ * The `map` function takes a callback function and applies it to each element in the deque,
752
+ * returning a new deque with the results.
753
+ * @param callback - The callback parameter is a function that will be called for each element in the
754
+ * deque. It takes three arguments: the current element, the index of the element, and the deque
755
+ * itself. It should return a value of type EM.
756
+ * @param [toElementFn] - The `toElementFn` parameter is an optional function that can be used to
757
+ * transform the raw element (`RM`) into a new element (`EM`) before adding it to the new deque. If
758
+ * provided, this function will be called for each raw element in the original deque.
759
+ * @param {any} [thisArg] - The `thisArg` parameter is an optional argument that allows you to
760
+ * specify the value of `this` within the callback function. It is used to set the context or scope
761
+ * in which the callback function will be executed. If `thisArg` is provided, it will be used as the
762
+ * value of
763
+ * @returns a new Deque object with elements of type EM and raw elements of type RM.
764
+ */
765
+ map(callback, toElementFn, thisArg) {
766
+ const newDeque = new Deque([], { bucketSize: this._bucketSize, toElementFn });
760
767
  let index = 0;
761
768
  for (const el of this) {
762
769
  newDeque.push(callback.call(thisArg, el, index, this));
@@ -767,9 +774,8 @@ export class Deque extends IterableElementBase {
767
774
  /**
768
775
  * Time Complexity: O(n)
769
776
  * Space Complexity: O(1)
770
- * /
771
-
772
- /**
777
+ */
778
+ /**
773
779
  * Time Complexity: O(n)
774
780
  * Space Complexity: O(1)
775
781
  *
@@ -3,7 +3,7 @@
3
3
  * @copyright Tyler Zeng <zrwusa@gmail.com>
4
4
  * @class
5
5
  */
6
- import type { ElementCallback } from '../../types';
6
+ import type { ElementCallback, QueueOptions } from '../../types';
7
7
  import { IterableElementBase } from '../base';
8
8
  import { SinglyLinkedList } from '../linked-list';
9
9
  /**
@@ -15,14 +15,8 @@ import { SinglyLinkedList } from '../linked-list';
15
15
  * 6. Breadth-First Search (BFS): In traversal algorithms for graphs and trees, queues store elements that are to be visited.
16
16
  * 7. Real-time Queuing: Like queuing systems in banks or supermarkets.
17
17
  */
18
- export declare class Queue<E = any> extends IterableElementBase<E> {
19
- /**
20
- * The constructor initializes an instance of a class with an optional array of elements and sets the offset to 0.
21
- * @param {E[]} [elements] - The `elements` parameter is an optional array of elements of type `E`. If provided, it
22
- * will be used to initialize the `_elements` property of the class. If not provided, the `_elements` property will be
23
- * initialized as an empty array.
24
- */
25
- constructor(elements?: Iterable<E>);
18
+ export declare class Queue<E = any, R = any> extends IterableElementBase<E, R, Queue<E, R>> {
19
+ constructor(elements?: Iterable<E> | Iterable<R>, options?: QueueOptions<E, R>);
26
20
  protected _elements: E[];
27
21
  /**
28
22
  * The elements function returns the elements of this set.
@@ -178,7 +172,7 @@ export declare class Queue<E = any> extends IterableElementBase<E> {
178
172
  * The `clone()` function returns a new Queue object with the same elements as the original Queue.
179
173
  * @returns The `clone()` method is returning a new instance of the `Queue` class.
180
174
  */
181
- clone(): Queue<E>;
175
+ clone(): Queue<E, R>;
182
176
  /**
183
177
  * Time Complexity: O(n)
184
178
  * Space Complexity: O(n)
@@ -199,26 +193,12 @@ export declare class Queue<E = any> extends IterableElementBase<E> {
199
193
  * @returns The `filter` method is returning a new `Queue` object that contains the elements that
200
194
  * satisfy the given predicate function.
201
195
  */
202
- filter(predicate: ElementCallback<E, boolean>, thisArg?: any): Queue<E>;
203
- /**
204
- * Time Complexity: O(n)
205
- * Space Complexity: O(n)
206
- */
196
+ filter(predicate: ElementCallback<E, R, boolean, Queue<E, R>>, thisArg?: any): Queue<E, R>;
207
197
  /**
208
198
  * Time Complexity: O(n)
209
199
  * Space Complexity: O(n)
210
- *
211
- * The `map` function takes a callback function and applies it to each element in the queue,
212
- * returning a new queue with the results.
213
- * @param callback - The callback parameter is a function that will be called for each element in the
214
- * queue. It takes three arguments: the current element, the index of the current element, and the
215
- * queue itself. The callback function should return a new value that will be added to the new queue.
216
- * @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
217
- * to be used as `this` when executing the `callback` function. If `thisArg` is provided, it will be
218
- * passed as the `this` value to the `callback` function. If `thisArg` is
219
- * @returns The `map` function is returning a new `Queue` object with the transformed elements.
220
200
  */
221
- map<T>(callback: ElementCallback<E, T>, thisArg?: any): Queue<T>;
201
+ map<EM, RM>(callback: ElementCallback<E, R, EM, Queue<E, R>>, toElementFn?: (rawElement: RM) => EM, thisArg?: any): Queue<EM, RM>;
222
202
  /**
223
203
  * Time Complexity: O(n)
224
204
  * Space Complexity: O(n)
@@ -237,7 +217,7 @@ export declare class Queue<E = any> extends IterableElementBase<E> {
237
217
  * 3. Memory Usage: Since each element requires additional space to store a pointer to the next element, linked lists may use more memory compared to arrays.
238
218
  * 4. Frequent Enqueuing and Dequeuing Operations: If your application involves frequent enqueuing and dequeuing operations and is less concerned with random access, then LinkedListQueue is a good choice.
239
219
  */
240
- export declare class LinkedListQueue<E = any> extends SinglyLinkedList<E> {
220
+ export declare class LinkedListQueue<E = any, R = any> extends SinglyLinkedList<E, R> {
241
221
  /**
242
222
  * Time Complexity: O(n)
243
223
  * Space Complexity: O(n)
@@ -250,5 +230,5 @@ export declare class LinkedListQueue<E = any> extends SinglyLinkedList<E> {
250
230
  * @returns The `clone()` method is returning a new instance of `LinkedListQueue` with the same
251
231
  * values as the original `LinkedListQueue`.
252
232
  */
253
- clone(): LinkedListQueue<E>;
233
+ clone(): LinkedListQueue<E, R>;
254
234
  }