data-structure-typed 2.6.1 → 2.6.2
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.
- package/CHANGELOG.md +9 -1
- package/dist/cjs/binary-tree.cjs +2927 -23688
- package/dist/cjs/graph.cjs +845 -2634
- package/dist/cjs/hash.cjs +185 -616
- package/dist/cjs/heap.cjs +266 -818
- package/dist/cjs/index.cjs +5116 -31358
- package/dist/cjs/linked-list.cjs +644 -2615
- package/dist/cjs/matrix.cjs +220 -535
- package/dist/cjs/priority-queue.cjs +266 -818
- package/dist/cjs/queue.cjs +637 -2343
- package/dist/cjs/stack.cjs +124 -530
- package/dist/cjs/trie.cjs +145 -592
- package/dist/cjs-legacy/binary-tree.cjs +4352 -25113
- package/dist/cjs-legacy/graph.cjs +847 -2636
- package/dist/cjs-legacy/hash.cjs +181 -612
- package/dist/cjs-legacy/heap.cjs +266 -818
- package/dist/cjs-legacy/index.cjs +6657 -32899
- package/dist/cjs-legacy/linked-list.cjs +640 -2611
- package/dist/cjs-legacy/matrix.cjs +220 -535
- package/dist/cjs-legacy/priority-queue.cjs +266 -818
- package/dist/cjs-legacy/queue.cjs +634 -2340
- package/dist/cjs-legacy/stack.cjs +124 -530
- package/dist/cjs-legacy/trie.cjs +145 -592
- package/dist/esm/binary-tree.mjs +2927 -23688
- package/dist/esm/graph.mjs +845 -2634
- package/dist/esm/hash.mjs +185 -616
- package/dist/esm/heap.mjs +266 -818
- package/dist/esm/index.mjs +5116 -31358
- package/dist/esm/linked-list.mjs +644 -2615
- package/dist/esm/matrix.mjs +220 -535
- package/dist/esm/priority-queue.mjs +266 -818
- package/dist/esm/queue.mjs +637 -2343
- package/dist/esm/stack.mjs +124 -530
- package/dist/esm/trie.mjs +145 -592
- package/dist/esm-legacy/binary-tree.mjs +4352 -25113
- package/dist/esm-legacy/graph.mjs +847 -2636
- package/dist/esm-legacy/hash.mjs +181 -612
- package/dist/esm-legacy/heap.mjs +266 -818
- package/dist/esm-legacy/index.mjs +6657 -32899
- package/dist/esm-legacy/linked-list.mjs +640 -2611
- package/dist/esm-legacy/matrix.mjs +220 -535
- package/dist/esm-legacy/priority-queue.mjs +266 -818
- package/dist/esm-legacy/queue.mjs +634 -2340
- package/dist/esm-legacy/stack.mjs +124 -530
- package/dist/esm-legacy/trie.mjs +145 -592
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +29 -500
- package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +38 -563
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +230 -1212
- package/dist/types/data-structures/binary-tree/bst.d.ts +124 -1063
- package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +99 -854
- package/dist/types/data-structures/binary-tree/segment-tree.d.ts +62 -314
- package/dist/types/data-structures/binary-tree/tree-map.d.ts +366 -5057
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +277 -4885
- package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +253 -3929
- package/dist/types/data-structures/binary-tree/tree-set.d.ts +261 -4782
- package/dist/types/data-structures/graph/abstract-graph.d.ts +44 -44
- package/dist/types/data-structures/graph/directed-graph.d.ts +130 -527
- package/dist/types/data-structures/graph/undirected-graph.d.ts +125 -482
- package/dist/types/data-structures/hash/hash-map.d.ts +132 -562
- package/dist/types/data-structures/heap/heap.d.ts +194 -746
- package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +120 -809
- package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +121 -733
- package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +193 -863
- package/dist/types/data-structures/matrix/matrix.d.ts +159 -474
- package/dist/types/data-structures/priority-queue/max-priority-queue.d.ts +1 -6
- package/dist/types/data-structures/priority-queue/min-priority-queue.d.ts +6 -11
- package/dist/types/data-structures/priority-queue/priority-queue.d.ts +1 -1
- package/dist/types/data-structures/queue/deque.d.ts +196 -804
- package/dist/types/data-structures/queue/queue.d.ts +99 -585
- package/dist/types/data-structures/stack/stack.d.ts +75 -481
- package/dist/types/data-structures/trie/trie.d.ts +98 -584
- package/dist/umd/data-structure-typed.js +6580 -32822
- package/dist/umd/data-structure-typed.min.js +3 -3
- package/docs-site-docusaurus/docs/api/classes/AVLTree.md +162 -215
- package/docs-site-docusaurus/docs/api/classes/AVLTreeNode.md +9 -9
- package/docs-site-docusaurus/docs/api/classes/AbstractGraph.md +47 -47
- package/docs-site-docusaurus/docs/api/classes/BST.md +155 -208
- package/docs-site-docusaurus/docs/api/classes/BSTNode.md +7 -7
- package/docs-site-docusaurus/docs/api/classes/BinaryIndexedTree.md +13 -29
- package/docs-site-docusaurus/docs/api/classes/BinaryTree.md +104 -158
- package/docs-site-docusaurus/docs/api/classes/BinaryTreeNode.md +13 -13
- package/docs-site-docusaurus/docs/api/classes/Deque.md +72 -104
- package/docs-site-docusaurus/docs/api/classes/DirectedGraph.md +60 -80
- package/docs-site-docusaurus/docs/api/classes/DoublyLinkedList.md +67 -101
- package/docs-site-docusaurus/docs/api/classes/DoublyLinkedListNode.md +6 -6
- package/docs-site-docusaurus/docs/api/classes/FibonacciHeap.md +9 -9
- package/docs-site-docusaurus/docs/api/classes/FibonacciHeapNode.md +1 -1
- package/docs-site-docusaurus/docs/api/classes/HashMap.md +52 -48
- package/docs-site-docusaurus/docs/api/classes/Heap.md +40 -68
- package/docs-site-docusaurus/docs/api/classes/IterableElementBase.md +17 -17
- package/docs-site-docusaurus/docs/api/classes/LinearBase.md +38 -38
- package/docs-site-docusaurus/docs/api/classes/LinearLinkedBase.md +45 -45
- package/docs-site-docusaurus/docs/api/classes/LinkedHashMap.md +23 -23
- package/docs-site-docusaurus/docs/api/classes/LinkedListQueue.md +68 -96
- package/docs-site-docusaurus/docs/api/classes/MapGraph.md +60 -80
- package/docs-site-docusaurus/docs/api/classes/Matrix.md +57 -52
- package/docs-site-docusaurus/docs/api/classes/MaxHeap.md +38 -66
- package/docs-site-docusaurus/docs/api/classes/MaxPriorityQueue.md +41 -74
- package/docs-site-docusaurus/docs/api/classes/MinHeap.md +38 -66
- package/docs-site-docusaurus/docs/api/classes/MinPriorityQueue.md +46 -79
- package/docs-site-docusaurus/docs/api/classes/PriorityQueue.md +40 -68
- package/docs-site-docusaurus/docs/api/classes/Queue.md +54 -78
- package/docs-site-docusaurus/docs/api/classes/RedBlackTree.md +171 -225
- package/docs-site-docusaurus/docs/api/classes/SegmentTree.md +10 -22
- package/docs-site-docusaurus/docs/api/classes/SinglyLinkedList.md +68 -98
- package/docs-site-docusaurus/docs/api/classes/SinglyLinkedListNode.md +4 -4
- package/docs-site-docusaurus/docs/api/classes/SkipList.md +98 -75
- package/docs-site-docusaurus/docs/api/classes/Stack.md +33 -53
- package/docs-site-docusaurus/docs/api/classes/TreeMap.md +104 -129
- package/docs-site-docusaurus/docs/api/classes/TreeMultiMap.md +57 -124
- package/docs-site-docusaurus/docs/api/classes/TreeSet.md +45 -116
- package/docs-site-docusaurus/docs/api/classes/Trie.md +37 -61
- package/docs-site-docusaurus/docs/api/classes/TrieNode.md +8 -8
- package/docs-site-docusaurus/docs/api/classes/UndirectedGraph.md +59 -77
- package/package.json +1 -1
- package/src/data-structures/binary-tree/tree-multi-set.ts +15 -11
|
@@ -127,116 +127,26 @@ export declare class Queue<E = any, R = any> extends LinearBase<E, R> {
|
|
|
127
127
|
* Get the number of elements currently in the queue.
|
|
128
128
|
* @remarks Time O(1), Space O(1)
|
|
129
129
|
* @returns Current length.
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
* @example
|
|
173
|
-
* // Track queue length
|
|
174
|
-
* const q = new Queue<number>();
|
|
175
|
-
* console.log(q.length); // 0;
|
|
176
|
-
* q.push(1);
|
|
177
|
-
* q.push(2);
|
|
178
|
-
* console.log(q.length); // 2;
|
|
130
|
+
* @example
|
|
131
|
+
* // Track queue length
|
|
132
|
+
* const q = new Queue<number>();
|
|
133
|
+
* console.log(q.length); // 0;
|
|
134
|
+
* q.push(1);
|
|
135
|
+
* q.push(2);
|
|
136
|
+
* console.log(q.length); // 2;
|
|
179
137
|
*/
|
|
180
138
|
get length(): number;
|
|
181
139
|
/**
|
|
182
140
|
* Get the first element (front) without removing it.
|
|
183
141
|
* @remarks Time O(1), Space O(1)
|
|
184
142
|
* @returns Front element or undefined.
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
* @example
|
|
228
|
-
* // View the front element
|
|
229
|
-
* const q = new Queue<string>(['first', 'second', 'third']);
|
|
230
|
-
* console.log(q.first); // 'first';
|
|
231
|
-
* console.log(q.length); // 3;
|
|
143
|
+
* @example
|
|
144
|
+
* // View the front element
|
|
145
|
+
* const q = new Queue<string>(['first', 'second', 'third']);
|
|
146
|
+
* console.log(q.first); // 'first';
|
|
147
|
+
* console.log(q.length); // 3;
|
|
232
148
|
*/
|
|
233
149
|
get first(): E | undefined;
|
|
234
|
-
/**
|
|
235
|
-
* Peek at the front element without removing it (alias for `first`).
|
|
236
|
-
* @remarks Time O(1), Space O(1)
|
|
237
|
-
* @returns Front element or undefined.
|
|
238
|
-
*/
|
|
239
|
-
peek(): E | undefined;
|
|
240
150
|
/**
|
|
241
151
|
* Get the last element (back) without removing it.
|
|
242
152
|
* @remarks Time O(1), Space O(1)
|
|
@@ -251,70 +161,34 @@ export declare class Queue<E = any, R = any> extends LinearBase<E, R> {
|
|
|
251
161
|
* @returns A new queue populated from the array.
|
|
252
162
|
*/
|
|
253
163
|
static fromArray<E>(elements: E[]): Queue<E>;
|
|
164
|
+
/**
|
|
165
|
+
* Peek at the front element without removing it (alias for `first`).
|
|
166
|
+
* @remarks Time O(1), Space O(1)
|
|
167
|
+
* @returns Front element or undefined.
|
|
168
|
+
*/
|
|
169
|
+
peek(): E | undefined;
|
|
254
170
|
/**
|
|
255
171
|
* Check whether the queue is empty.
|
|
256
172
|
* @remarks Time O(1), Space O(1)
|
|
257
173
|
* @returns True if length is 0.
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
* @example
|
|
301
|
-
* // Queue for...of iteration and isEmpty check
|
|
302
|
-
* const queue = new Queue<string>(['A', 'B', 'C', 'D']);
|
|
303
|
-
*
|
|
304
|
-
* const elements: string[] = [];
|
|
305
|
-
* for (const item of queue) {
|
|
306
|
-
* elements.push(item);
|
|
307
|
-
* }
|
|
308
|
-
*
|
|
309
|
-
* // Verify all elements are iterated in order
|
|
310
|
-
* console.log(elements); // ['A', 'B', 'C', 'D'];
|
|
311
|
-
*
|
|
312
|
-
* // Process all elements
|
|
313
|
-
* while (queue.length > 0) {
|
|
314
|
-
* queue.shift();
|
|
315
|
-
* }
|
|
316
|
-
*
|
|
317
|
-
* console.log(queue.length); // 0;
|
|
174
|
+
* @example
|
|
175
|
+
* // Queue for...of iteration and isEmpty check
|
|
176
|
+
* const queue = new Queue<string>(['A', 'B', 'C', 'D']);
|
|
177
|
+
*
|
|
178
|
+
* const elements: string[] = [];
|
|
179
|
+
* for (const item of queue) {
|
|
180
|
+
* elements.push(item);
|
|
181
|
+
* }
|
|
182
|
+
*
|
|
183
|
+
* // Verify all elements are iterated in order
|
|
184
|
+
* console.log(elements); // ['A', 'B', 'C', 'D'];
|
|
185
|
+
*
|
|
186
|
+
* // Process all elements
|
|
187
|
+
* while (queue.length > 0) {
|
|
188
|
+
* queue.shift();
|
|
189
|
+
* }
|
|
190
|
+
*
|
|
191
|
+
* console.log(queue.length); // 0;
|
|
318
192
|
*/
|
|
319
193
|
isEmpty(): boolean;
|
|
320
194
|
/**
|
|
@@ -322,58 +196,16 @@ export declare class Queue<E = any, R = any> extends LinearBase<E, R> {
|
|
|
322
196
|
* @remarks Time O(1), Space O(1)
|
|
323
197
|
* @param element - Element to enqueue.
|
|
324
198
|
* @returns True on success.
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
* @example
|
|
368
|
-
* // basic Queue creation and push operation
|
|
369
|
-
* // Create a simple Queue with initial values
|
|
370
|
-
* const queue = new Queue([1, 2, 3, 4, 5]);
|
|
371
|
-
*
|
|
372
|
-
* // Verify the queue maintains insertion order
|
|
373
|
-
* console.log([...queue]); // [1, 2, 3, 4, 5];
|
|
374
|
-
*
|
|
375
|
-
* // Check length
|
|
376
|
-
* console.log(queue.length); // 5;
|
|
199
|
+
* @example
|
|
200
|
+
* // basic Queue creation and push operation
|
|
201
|
+
* // Create a simple Queue with initial values
|
|
202
|
+
* const queue = new Queue([1, 2, 3, 4, 5]);
|
|
203
|
+
*
|
|
204
|
+
* // Verify the queue maintains insertion order
|
|
205
|
+
* console.log([...queue]); // [1, 2, 3, 4, 5];
|
|
206
|
+
*
|
|
207
|
+
* // Check length
|
|
208
|
+
* console.log(queue.length); // 5;
|
|
377
209
|
*/
|
|
378
210
|
push(element: E): boolean;
|
|
379
211
|
/**
|
|
@@ -387,62 +219,20 @@ export declare class Queue<E = any, R = any> extends LinearBase<E, R> {
|
|
|
387
219
|
* Dequeue one element from the front (amortized via offset).
|
|
388
220
|
* @remarks Time O(1) amortized, Space O(1)
|
|
389
221
|
* @returns Removed element or undefined.
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
* @example
|
|
433
|
-
* // Queue shift and peek operations
|
|
434
|
-
* const queue = new Queue<number>([10, 20, 30, 40]);
|
|
435
|
-
*
|
|
436
|
-
* // Peek at the front element without removing it
|
|
437
|
-
* console.log(queue.first); // 10;
|
|
438
|
-
*
|
|
439
|
-
* // Remove and get the first element (FIFO)
|
|
440
|
-
* const first = queue.shift();
|
|
441
|
-
* console.log(first); // 10;
|
|
442
|
-
*
|
|
443
|
-
* // Verify remaining elements and length decreased
|
|
444
|
-
* console.log([...queue]); // [20, 30, 40];
|
|
445
|
-
* console.log(queue.length); // 3;
|
|
222
|
+
* @example
|
|
223
|
+
* // Queue shift and peek operations
|
|
224
|
+
* const queue = new Queue<number>([10, 20, 30, 40]);
|
|
225
|
+
*
|
|
226
|
+
* // Peek at the front element without removing it
|
|
227
|
+
* console.log(queue.first); // 10;
|
|
228
|
+
*
|
|
229
|
+
* // Remove and get the first element (FIFO)
|
|
230
|
+
* const first = queue.shift();
|
|
231
|
+
* console.log(first); // 10;
|
|
232
|
+
*
|
|
233
|
+
* // Verify remaining elements and length decreased
|
|
234
|
+
* console.log([...queue]); // [20, 30, 40];
|
|
235
|
+
* console.log(queue.length); // 3;
|
|
446
236
|
*/
|
|
447
237
|
shift(): E | undefined;
|
|
448
238
|
/**
|
|
@@ -450,50 +240,11 @@ export declare class Queue<E = any, R = any> extends LinearBase<E, R> {
|
|
|
450
240
|
* @remarks Time O(N), Space O(1)
|
|
451
241
|
* @param element - Element to remove (strict equality via Object.is).
|
|
452
242
|
* @returns True if an element was removed.
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
* @example
|
|
493
|
-
* // Remove specific element
|
|
494
|
-
* const q = new Queue<number>([1, 2, 3, 2]);
|
|
495
|
-
* q.delete(2);
|
|
496
|
-
* console.log(q.length); // 3;
|
|
243
|
+
* @example
|
|
244
|
+
* // Remove specific element
|
|
245
|
+
* const q = new Queue<number>([1, 2, 3, 2]);
|
|
246
|
+
* q.delete(2);
|
|
247
|
+
* console.log(q.length); // 3;
|
|
497
248
|
*/
|
|
498
249
|
delete(element: E): boolean;
|
|
499
250
|
/**
|
|
@@ -501,50 +252,11 @@ export declare class Queue<E = any, R = any> extends LinearBase<E, R> {
|
|
|
501
252
|
* @remarks Time O(1), Space O(1)
|
|
502
253
|
* @param index - Zero-based index from the front.
|
|
503
254
|
* @returns Element or undefined.
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
* @example
|
|
544
|
-
* // Access element by index
|
|
545
|
-
* const q = new Queue<string>(['a', 'b', 'c']);
|
|
546
|
-
* console.log(q.at(0)); // 'a';
|
|
547
|
-
* console.log(q.at(2)); // 'c';
|
|
255
|
+
* @example
|
|
256
|
+
* // Access element by index
|
|
257
|
+
* const q = new Queue<string>(['a', 'b', 'c']);
|
|
258
|
+
* console.log(q.at(0)); // 'a';
|
|
259
|
+
* console.log(q.at(2)); // 'c';
|
|
548
260
|
*/
|
|
549
261
|
at(index: number): E | undefined;
|
|
550
262
|
/**
|
|
@@ -587,103 +299,24 @@ export declare class Queue<E = any, R = any> extends LinearBase<E, R> {
|
|
|
587
299
|
* Remove all elements and reset offset.
|
|
588
300
|
* @remarks Time O(1), Space O(1)
|
|
589
301
|
* @returns void
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
* @example
|
|
631
|
-
* // Remove all elements
|
|
632
|
-
* const q = new Queue<number>([1, 2, 3]);
|
|
633
|
-
* q.clear();
|
|
634
|
-
* console.log(q.length); // 0;
|
|
302
|
+
* @example
|
|
303
|
+
* // Remove all elements
|
|
304
|
+
* const q = new Queue<number>([1, 2, 3]);
|
|
305
|
+
* q.clear();
|
|
306
|
+
* console.log(q.length); // 0;
|
|
635
307
|
*/
|
|
636
308
|
clear(): void;
|
|
637
309
|
/**
|
|
638
310
|
* Compact storage by discarding consumed head elements.
|
|
639
311
|
* @remarks Time O(N), Space O(N)
|
|
640
312
|
* @returns True when compaction performed.
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
* @example
|
|
681
|
-
* // Reclaim unused memory
|
|
682
|
-
* const q = new Queue<number>([1, 2, 3, 4, 5]);
|
|
683
|
-
* q.shift();
|
|
684
|
-
* q.shift();
|
|
685
|
-
* q.compact();
|
|
686
|
-
* console.log(q.length); // 3;
|
|
313
|
+
* @example
|
|
314
|
+
* // Reclaim unused memory
|
|
315
|
+
* const q = new Queue<number>([1, 2, 3, 4, 5]);
|
|
316
|
+
* q.shift();
|
|
317
|
+
* q.shift();
|
|
318
|
+
* q.compact();
|
|
319
|
+
* console.log(q.length); // 3;
|
|
687
320
|
*/
|
|
688
321
|
compact(): boolean;
|
|
689
322
|
/**
|
|
@@ -699,53 +332,13 @@ export declare class Queue<E = any, R = any> extends LinearBase<E, R> {
|
|
|
699
332
|
* Deep clone this queue and its parameters.
|
|
700
333
|
* @remarks Time O(N), Space O(N)
|
|
701
334
|
* @returns A new queue with the same content and options.
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
* @example
|
|
743
|
-
* // Create independent copy
|
|
744
|
-
* const q = new Queue<number>([1, 2, 3]);
|
|
745
|
-
* const copy = q.clone();
|
|
746
|
-
* copy.shift();
|
|
747
|
-
* console.log(q.length); // 3;
|
|
748
|
-
* console.log(copy.length); // 2;
|
|
335
|
+
* @example
|
|
336
|
+
* // Create independent copy
|
|
337
|
+
* const q = new Queue<number>([1, 2, 3]);
|
|
338
|
+
* const copy = q.clone();
|
|
339
|
+
* copy.shift();
|
|
340
|
+
* console.log(q.length); // 3;
|
|
341
|
+
* console.log(copy.length); // 2;
|
|
749
342
|
*/
|
|
750
343
|
clone(): this;
|
|
751
344
|
/**
|
|
@@ -754,51 +347,11 @@ export declare class Queue<E = any, R = any> extends LinearBase<E, R> {
|
|
|
754
347
|
* @param predicate - Predicate (element, index, queue) → boolean to keep element.
|
|
755
348
|
* @param [thisArg] - Value for `this` inside the predicate.
|
|
756
349
|
* @returns A new queue with kept elements.
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
* @example
|
|
798
|
-
* // Filter elements
|
|
799
|
-
* const q = new Queue<number>([1, 2, 3, 4, 5]);
|
|
800
|
-
* const evens = q.filter(x => x % 2 === 0);
|
|
801
|
-
* console.log(evens.length); // 2;
|
|
350
|
+
* @example
|
|
351
|
+
* // Filter elements
|
|
352
|
+
* const q = new Queue<number>([1, 2, 3, 4, 5]);
|
|
353
|
+
* const evens = q.filter(x => x % 2 === 0);
|
|
354
|
+
* console.log(evens.length); // 2;
|
|
802
355
|
*/
|
|
803
356
|
filter(predicate: ElementCallback<E, R, boolean>, thisArg?: unknown): this;
|
|
804
357
|
/**
|
|
@@ -810,50 +363,11 @@ export declare class Queue<E = any, R = any> extends LinearBase<E, R> {
|
|
|
810
363
|
* @param [options] - Options for the output queue (e.g., toElementFn, maxLen, autoCompactRatio).
|
|
811
364
|
* @param [thisArg] - Value for `this` inside the callback.
|
|
812
365
|
* @returns A new Queue with mapped elements.
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
* @example
|
|
853
|
-
* // Transform elements
|
|
854
|
-
* const q = new Queue<number>([1, 2, 3]);
|
|
855
|
-
* const doubled = q.map(x => x * 2);
|
|
856
|
-
* console.log(doubled.toArray()); // [2, 4, 6];
|
|
366
|
+
* @example
|
|
367
|
+
* // Transform elements
|
|
368
|
+
* const q = new Queue<number>([1, 2, 3]);
|
|
369
|
+
* const doubled = q.map(x => x * 2);
|
|
370
|
+
* console.log(doubled.toArray()); // [2, 4, 6];
|
|
857
371
|
*/
|
|
858
372
|
map<EM, RM>(callback: ElementCallback<E, R, EM>, options?: QueueOptions<EM, RM>, thisArg?: unknown): Queue<EM, RM>;
|
|
859
373
|
/**
|