data-structure-typed 2.6.0 → 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/.github/workflows/ci.yml +7 -2
- package/.github/workflows/release-package.yml +9 -2
- 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 +253 -101
- package/docs-site-docusaurus/docs/api/classes/DirectedGraph.md +60 -80
- package/docs-site-docusaurus/docs/api/classes/DoublyLinkedList.md +244 -114
- 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 +119 -64
- package/docs-site-docusaurus/docs/api/classes/IterableElementBase.md +84 -14
- package/docs-site-docusaurus/docs/api/classes/LinearBase.md +138 -34
- package/docs-site-docusaurus/docs/api/classes/LinearLinkedBase.md +149 -41
- package/docs-site-docusaurus/docs/api/classes/LinkedHashMap.md +23 -23
- package/docs-site-docusaurus/docs/api/classes/LinkedListQueue.md +172 -92
- 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 +117 -62
- package/docs-site-docusaurus/docs/api/classes/MaxPriorityQueue.md +120 -70
- package/docs-site-docusaurus/docs/api/classes/MinHeap.md +117 -62
- package/docs-site-docusaurus/docs/api/classes/MinPriorityQueue.md +125 -75
- package/docs-site-docusaurus/docs/api/classes/PriorityQueue.md +119 -64
- package/docs-site-docusaurus/docs/api/classes/Queue.md +158 -74
- 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 +172 -94
- 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 +112 -50
- package/docs-site-docusaurus/docs/api/classes/TreeMap.md +104 -129
- package/docs-site-docusaurus/docs/api/classes/TreeMultiMap.md +90 -121
- package/docs-site-docusaurus/docs/api/classes/TreeSet.md +298 -107
- package/docs-site-docusaurus/docs/api/classes/Trie.md +116 -58
- 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 +45 -46
- package/src/common/error.ts +15 -32
- package/src/common/index.ts +0 -3
- package/src/data-structures/base/iterable-element-base.ts +0 -3
- package/src/data-structures/base/linear-base.ts +2 -36
- package/src/data-structures/binary-tree/avl-tree.ts +31 -529
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +47 -572
- package/src/data-structures/binary-tree/binary-tree.ts +326 -1311
- package/src/data-structures/binary-tree/bst.ts +158 -1082
- package/src/data-structures/binary-tree/red-black-tree.ts +451 -1290
- package/src/data-structures/binary-tree/segment-tree.ts +73 -351
- package/src/data-structures/binary-tree/tree-map.ts +462 -5124
- package/src/data-structures/binary-tree/tree-multi-map.ts +302 -4914
- package/src/data-structures/binary-tree/tree-multi-set.ts +299 -3983
- package/src/data-structures/binary-tree/tree-set.ts +338 -4836
- package/src/data-structures/graph/abstract-graph.ts +98 -167
- package/src/data-structures/graph/directed-graph.ts +137 -562
- package/src/data-structures/graph/map-graph.ts +0 -3
- package/src/data-structures/graph/undirected-graph.ts +132 -511
- package/src/data-structures/hash/hash-map.ts +154 -582
- package/src/data-structures/heap/heap.ts +200 -795
- package/src/data-structures/linked-list/doubly-linked-list.ts +121 -865
- package/src/data-structures/linked-list/singly-linked-list.ts +122 -794
- package/src/data-structures/linked-list/skip-linked-list.ts +211 -918
- package/src/data-structures/matrix/matrix.ts +179 -518
- package/src/data-structures/matrix/navigator.ts +0 -1
- package/src/data-structures/priority-queue/max-priority-queue.ts +1 -6
- package/src/data-structures/priority-queue/min-priority-queue.ts +6 -11
- package/src/data-structures/priority-queue/priority-queue.ts +1 -2
- package/src/data-structures/queue/deque.ts +214 -882
- package/src/data-structures/queue/queue.ts +102 -625
- package/src/data-structures/stack/stack.ts +76 -505
- package/src/data-structures/trie/trie.ts +98 -628
- package/src/types/common.ts +0 -10
- package/src/types/data-structures/binary-tree/bst.ts +0 -7
- package/src/types/data-structures/binary-tree/red-black-tree.ts +0 -1
- package/src/types/data-structures/graph/abstract-graph.ts +0 -2
- package/src/types/data-structures/hash/hash-map.ts +0 -3
- package/src/types/data-structures/hash/index.ts +0 -1
- package/src/types/data-structures/matrix/navigator.ts +0 -2
- package/src/types/utils/utils.ts +0 -7
- package/src/types/utils/validate-type.ts +0 -7
- package/src/utils/number.ts +0 -2
- package/src/utils/utils.ts +0 -5
|
@@ -74,7 +74,11 @@ import { LinearBase } from '../base/linear-base';
|
|
|
74
74
|
* console.log(dq.toArray()); // [10, 20, 30];
|
|
75
75
|
*/
|
|
76
76
|
export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
|
|
77
|
-
|
|
77
|
+
/**
|
|
78
|
+
* Counter for shift/pop operations since last compaction check.
|
|
79
|
+
* Only checks ratio every `_bucketSize` operations to minimize overhead.
|
|
80
|
+
*/
|
|
81
|
+
protected _compactCounter: number;
|
|
78
82
|
/**
|
|
79
83
|
* Create a Deque and optionally bulk-insert elements.
|
|
80
84
|
* @remarks Time O(N), Space O(N)
|
|
@@ -108,11 +112,6 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
|
|
|
108
112
|
* @param value - Ratio in [0,1]. 0 disables auto-compact.
|
|
109
113
|
*/
|
|
110
114
|
set autoCompactRatio(value: number);
|
|
111
|
-
/**
|
|
112
|
-
* Counter for shift/pop operations since last compaction check.
|
|
113
|
-
* Only checks ratio every `_bucketSize` operations to minimize overhead.
|
|
114
|
-
*/
|
|
115
|
-
protected _compactCounter: number;
|
|
116
115
|
protected _bucketFirst: number;
|
|
117
116
|
/**
|
|
118
117
|
* Get the index of the first bucket in use.
|
|
@@ -163,140 +162,32 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
|
|
|
163
162
|
*/
|
|
164
163
|
get length(): number;
|
|
165
164
|
/**
|
|
166
|
-
*
|
|
167
|
-
* @
|
|
168
|
-
*
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
* @example
|
|
208
|
-
* // Deque peek at both ends
|
|
209
|
-
* const deque = new Deque<number>([10, 20, 30, 40, 50]);
|
|
210
|
-
*
|
|
211
|
-
* // Get first element without removing
|
|
212
|
-
* const first = deque.at(0);
|
|
213
|
-
* console.log(first); // 10;
|
|
214
|
-
*
|
|
215
|
-
* // Get last element without removing
|
|
216
|
-
* const last = deque.at(deque.length - 1);
|
|
217
|
-
* console.log(last); // 50;
|
|
218
|
-
*
|
|
219
|
-
* // Length unchanged
|
|
220
|
-
* console.log(deque.length); // 5;
|
|
221
|
-
*/
|
|
222
|
-
/**
|
|
223
|
-
* Peek at the front element without removing it (alias for `first`).
|
|
224
|
-
* @remarks Time O(1), Space O(1)
|
|
225
|
-
* @returns Front element or undefined.
|
|
165
|
+
* Deque peek at both ends
|
|
166
|
+
* @example
|
|
167
|
+
* // Deque peek at both ends
|
|
168
|
+
* const deque = new Deque<number>([10, 20, 30, 40, 50]);
|
|
169
|
+
*
|
|
170
|
+
* // Get first element without removing
|
|
171
|
+
* const first = deque.at(0);
|
|
172
|
+
* console.log(first); // 10;
|
|
173
|
+
*
|
|
174
|
+
* // Get last element without removing
|
|
175
|
+
* const last = deque.at(deque.length - 1);
|
|
176
|
+
* console.log(last); // 50;
|
|
177
|
+
*
|
|
178
|
+
* // Length unchanged
|
|
179
|
+
* console.log(deque.length); // 5;
|
|
226
180
|
*/
|
|
227
|
-
peek(): E | undefined;
|
|
228
|
-
/**
|
|
229
|
-
* Deque peek at both ends
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
* @example
|
|
234
|
-
* // Deque peek at both ends
|
|
235
|
-
* const deque = new Deque<number>([10, 20, 30, 40, 50]);
|
|
236
|
-
*
|
|
237
|
-
* // Get first element without removing
|
|
238
|
-
* const first = deque.at(0);
|
|
239
|
-
* console.log(first); // 10;
|
|
240
|
-
*
|
|
241
|
-
* // Get last element without removing
|
|
242
|
-
* const last = deque.at(deque.length - 1);
|
|
243
|
-
* console.log(last); // 50;
|
|
244
|
-
*
|
|
245
|
-
* // Length unchanged
|
|
246
|
-
* console.log(deque.length); // 5;
|
|
247
|
-
*/
|
|
248
181
|
get first(): E | undefined;
|
|
249
182
|
/**
|
|
250
183
|
* Get the last element without removing it.
|
|
251
184
|
* @remarks Time O(1), Space O(1)
|
|
252
185
|
* @returns Last element or undefined.
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
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
|
-
* @example
|
|
296
|
-
* // Peek at the back element
|
|
297
|
-
* const dq = new Deque<string>(['a', 'b', 'c']);
|
|
298
|
-
* console.log(dq.last); // 'c';
|
|
299
|
-
* console.log(dq.first); // 'a';
|
|
186
|
+
* @example
|
|
187
|
+
* // Peek at the back element
|
|
188
|
+
* const dq = new Deque<string>(['a', 'b', 'c']);
|
|
189
|
+
* console.log(dq.last); // 'c';
|
|
190
|
+
* console.log(dq.first); // 'a';
|
|
300
191
|
*/
|
|
301
192
|
get last(): E | undefined;
|
|
302
193
|
/**
|
|
@@ -310,177 +201,76 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
|
|
|
310
201
|
* @returns A new Deque populated from the array.
|
|
311
202
|
*/
|
|
312
203
|
static fromArray<E, R = any>(this: new (elements?: IterableWithSizeOrLength<E> | IterableWithSizeOrLength<R>, options?: DequeOptions<E, R>) => any, data: E[], options?: DequeOptions<E, R>): any;
|
|
204
|
+
/**
|
|
205
|
+
* Get the first element without removing it.
|
|
206
|
+
* @remarks Time O(1), Space O(1)
|
|
207
|
+
* @returns First element or undefined.
|
|
208
|
+
* @example
|
|
209
|
+
* // Deque peek at both ends
|
|
210
|
+
* const deque = new Deque<number>([10, 20, 30, 40, 50]);
|
|
211
|
+
*
|
|
212
|
+
* // Get first element without removing
|
|
213
|
+
* const first = deque.at(0);
|
|
214
|
+
* console.log(first); // 10;
|
|
215
|
+
*
|
|
216
|
+
* // Get last element without removing
|
|
217
|
+
* const last = deque.at(deque.length - 1);
|
|
218
|
+
* console.log(last); // 50;
|
|
219
|
+
*
|
|
220
|
+
* // Length unchanged
|
|
221
|
+
* console.log(deque.length); // 5;
|
|
222
|
+
*/
|
|
223
|
+
/**
|
|
224
|
+
* Peek at the front element without removing it (alias for `first`).
|
|
225
|
+
* @remarks Time O(1), Space O(1)
|
|
226
|
+
* @returns Front element or undefined.
|
|
227
|
+
*/
|
|
228
|
+
peek(): E | undefined;
|
|
313
229
|
/**
|
|
314
230
|
* Append one element at the back.
|
|
315
231
|
* @remarks Time O(1) amortized, Space O(1)
|
|
316
232
|
* @param element - Element to append.
|
|
317
233
|
* @returns True when appended.
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
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
|
-
* @example
|
|
361
|
-
* // basic Deque creation and push/pop operations
|
|
362
|
-
* // Create a simple Deque with initial values
|
|
363
|
-
* const deque = new Deque([1, 2, 3, 4, 5]);
|
|
364
|
-
*
|
|
365
|
-
* // Verify the deque maintains insertion order
|
|
366
|
-
* console.log([...deque]); // [1, 2, 3, 4, 5];
|
|
367
|
-
*
|
|
368
|
-
* // Check length
|
|
369
|
-
* console.log(deque.length); // 5;
|
|
370
|
-
*
|
|
371
|
-
* // Push to the end
|
|
372
|
-
* deque.push(6);
|
|
373
|
-
* console.log(deque.length); // 6;
|
|
374
|
-
*
|
|
375
|
-
* // Pop from the end
|
|
376
|
-
* const last = deque.pop();
|
|
377
|
-
* console.log(last); // 6;
|
|
234
|
+
* @example
|
|
235
|
+
* // basic Deque creation and push/pop operations
|
|
236
|
+
* // Create a simple Deque with initial values
|
|
237
|
+
* const deque = new Deque([1, 2, 3, 4, 5]);
|
|
238
|
+
*
|
|
239
|
+
* // Verify the deque maintains insertion order
|
|
240
|
+
* console.log([...deque]); // [1, 2, 3, 4, 5];
|
|
241
|
+
*
|
|
242
|
+
* // Check length
|
|
243
|
+
* console.log(deque.length); // 5;
|
|
244
|
+
*
|
|
245
|
+
* // Push to the end
|
|
246
|
+
* deque.push(6);
|
|
247
|
+
* console.log(deque.length); // 6;
|
|
248
|
+
*
|
|
249
|
+
* // Pop from the end
|
|
250
|
+
* const last = deque.pop();
|
|
251
|
+
* console.log(last); // 6;
|
|
378
252
|
*/
|
|
379
253
|
push(element: E): boolean;
|
|
380
254
|
/**
|
|
381
255
|
* Remove and return the last element.
|
|
382
256
|
* @remarks Time O(1), Space O(1)
|
|
383
257
|
* @returns Removed element or undefined.
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
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
|
-
* @example
|
|
427
|
-
* // Remove from the back
|
|
428
|
-
* const dq = new Deque<number>([1, 2, 3]);
|
|
429
|
-
* console.log(dq.pop()); // 3;
|
|
430
|
-
* console.log(dq.length); // 2;
|
|
258
|
+
* @example
|
|
259
|
+
* // Remove from the back
|
|
260
|
+
* const dq = new Deque<number>([1, 2, 3]);
|
|
261
|
+
* console.log(dq.pop()); // 3;
|
|
262
|
+
* console.log(dq.length); // 2;
|
|
431
263
|
*/
|
|
432
264
|
pop(): E | undefined;
|
|
433
265
|
/**
|
|
434
266
|
* Remove and return the first element.
|
|
435
267
|
* @remarks Time O(1) amortized, Space O(1)
|
|
436
268
|
* @returns Removed element or undefined.
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
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
|
-
* @example
|
|
480
|
-
* // Remove from the front
|
|
481
|
-
* const dq = new Deque<number>([1, 2, 3]);
|
|
482
|
-
* console.log(dq.shift()); // 1;
|
|
483
|
-
* console.log(dq.length); // 2;
|
|
269
|
+
* @example
|
|
270
|
+
* // Remove from the front
|
|
271
|
+
* const dq = new Deque<number>([1, 2, 3]);
|
|
272
|
+
* console.log(dq.shift()); // 1;
|
|
273
|
+
* console.log(dq.length); // 2;
|
|
484
274
|
*/
|
|
485
275
|
shift(): E | undefined;
|
|
486
276
|
/**
|
|
@@ -488,63 +278,21 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
|
|
|
488
278
|
* @remarks Time O(1) amortized, Space O(1)
|
|
489
279
|
* @param element - Element to prepend.
|
|
490
280
|
* @returns True when prepended.
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
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
|
-
* @example
|
|
534
|
-
* // Deque shift and unshift operations
|
|
535
|
-
* const deque = new Deque<number>([20, 30, 40]);
|
|
536
|
-
*
|
|
537
|
-
* // Unshift adds to the front
|
|
538
|
-
* deque.unshift(10);
|
|
539
|
-
* console.log([...deque]); // [10, 20, 30, 40];
|
|
540
|
-
*
|
|
541
|
-
* // Shift removes from the front (O(1) complexity!)
|
|
542
|
-
* const first = deque.shift();
|
|
543
|
-
* console.log(first); // 10;
|
|
544
|
-
*
|
|
545
|
-
* // Verify remaining elements
|
|
546
|
-
* console.log([...deque]); // [20, 30, 40];
|
|
547
|
-
* console.log(deque.length); // 3;
|
|
281
|
+
* @example
|
|
282
|
+
* // Deque shift and unshift operations
|
|
283
|
+
* const deque = new Deque<number>([20, 30, 40]);
|
|
284
|
+
*
|
|
285
|
+
* // Unshift adds to the front
|
|
286
|
+
* deque.unshift(10);
|
|
287
|
+
* console.log([...deque]); // [10, 20, 30, 40];
|
|
288
|
+
*
|
|
289
|
+
* // Shift removes from the front (O(1) complexity!)
|
|
290
|
+
* const first = deque.shift();
|
|
291
|
+
* console.log(first); // 10;
|
|
292
|
+
*
|
|
293
|
+
* // Verify remaining elements
|
|
294
|
+
* console.log([...deque]); // [20, 30, 40];
|
|
295
|
+
* console.log(deque.length); // 3;
|
|
548
296
|
*/
|
|
549
297
|
unshift(element: E): boolean;
|
|
550
298
|
/**
|
|
@@ -565,101 +313,21 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
|
|
|
565
313
|
* Check whether the deque is empty.
|
|
566
314
|
* @remarks Time O(1), Space O(1)
|
|
567
315
|
* @returns True if length is 0.
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
* @example
|
|
609
|
-
* // Check if empty
|
|
610
|
-
* const dq = new Deque();
|
|
611
|
-
* console.log(dq.isEmpty()); // true;
|
|
316
|
+
* @example
|
|
317
|
+
* // Check if empty
|
|
318
|
+
* const dq = new Deque();
|
|
319
|
+
* console.log(dq.isEmpty()); // true;
|
|
612
320
|
*/
|
|
613
321
|
isEmpty(): boolean;
|
|
614
322
|
/**
|
|
615
323
|
* Remove all elements and reset structure.
|
|
616
324
|
* @remarks Time O(1), Space O(1)
|
|
617
325
|
* @returns void
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
* @example
|
|
659
|
-
* // Remove all elements
|
|
660
|
-
* const dq = new Deque<number>([1, 2, 3]);
|
|
661
|
-
* dq.clear();
|
|
662
|
-
* console.log(dq.length); // 0;
|
|
326
|
+
* @example
|
|
327
|
+
* // Remove all elements
|
|
328
|
+
* const dq = new Deque<number>([1, 2, 3]);
|
|
329
|
+
* dq.clear();
|
|
330
|
+
* console.log(dq.length); // 0;
|
|
663
331
|
*/
|
|
664
332
|
clear(): void;
|
|
665
333
|
/**
|
|
@@ -667,50 +335,11 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
|
|
|
667
335
|
* @remarks Time O(1), Space O(1)
|
|
668
336
|
* @param pos - Zero-based position from the front.
|
|
669
337
|
* @returns Element or undefined.
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
* @example
|
|
710
|
-
* // Access by index
|
|
711
|
-
* const dq = new Deque<string>(['a', 'b', 'c']);
|
|
712
|
-
* console.log(dq.at(0)); // 'a';
|
|
713
|
-
* console.log(dq.at(2)); // 'c';
|
|
338
|
+
* @example
|
|
339
|
+
* // Access by index
|
|
340
|
+
* const dq = new Deque<string>(['a', 'b', 'c']);
|
|
341
|
+
* console.log(dq.at(0)); // 'a';
|
|
342
|
+
* console.log(dq.at(2)); // 'c';
|
|
714
343
|
*/
|
|
715
344
|
at(pos: number): E | undefined;
|
|
716
345
|
/**
|
|
@@ -767,50 +396,11 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
|
|
|
767
396
|
* @remarks Time O(N), Space O(1)
|
|
768
397
|
* @param element - Element to remove (using the configured equality).
|
|
769
398
|
* @returns True if an element was removed.
|
|
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
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
* @example
|
|
810
|
-
* // Remove element
|
|
811
|
-
* const dq = new Deque<number>([1, 2, 3]);
|
|
812
|
-
* dq.delete(2);
|
|
813
|
-
* console.log(dq.length); // 2;
|
|
399
|
+
* @example
|
|
400
|
+
* // Remove element
|
|
401
|
+
* const dq = new Deque<number>([1, 2, 3]);
|
|
402
|
+
* dq.delete(2);
|
|
403
|
+
* console.log(dq.length); // 2;
|
|
814
404
|
*/
|
|
815
405
|
delete(element: E): boolean;
|
|
816
406
|
/**
|
|
@@ -831,74 +421,35 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
|
|
|
831
421
|
* Reverse the deque by reversing buckets and pointers.
|
|
832
422
|
* @remarks Time O(N), Space O(N)
|
|
833
423
|
* @returns This deque.
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
* @example
|
|
874
|
-
* // Deque for...of iteration and reverse
|
|
875
|
-
* const deque = new Deque<string>(['A', 'B', 'C', 'D']);
|
|
876
|
-
*
|
|
877
|
-
* // Iterate forward
|
|
878
|
-
* const forward: string[] = [];
|
|
879
|
-
* for (const item of deque) {
|
|
880
|
-
* forward.push(item);
|
|
881
|
-
* }
|
|
882
|
-
* console.log(forward); // ['A', 'B', 'C', 'D'];
|
|
883
|
-
*
|
|
884
|
-
* // Reverse the deque
|
|
885
|
-
* deque.reverse();
|
|
886
|
-
* const backward: string[] = [];
|
|
887
|
-
* for (const item of deque) {
|
|
888
|
-
* backward.push(item);
|
|
889
|
-
* }
|
|
890
|
-
* console.log(backward); // ['D', 'C', 'B', 'A'];
|
|
424
|
+
* @example
|
|
425
|
+
* // Deque for...of iteration and reverse
|
|
426
|
+
* const deque = new Deque<string>(['A', 'B', 'C', 'D']);
|
|
427
|
+
*
|
|
428
|
+
* // Iterate forward
|
|
429
|
+
* const forward: string[] = [];
|
|
430
|
+
* for (const item of deque) {
|
|
431
|
+
* forward.push(item);
|
|
432
|
+
* }
|
|
433
|
+
* console.log(forward); // ['A', 'B', 'C', 'D'];
|
|
434
|
+
*
|
|
435
|
+
* // Reverse the deque
|
|
436
|
+
* deque.reverse();
|
|
437
|
+
* const backward: string[] = [];
|
|
438
|
+
* for (const item of deque) {
|
|
439
|
+
* backward.push(item);
|
|
440
|
+
* }
|
|
441
|
+
* console.log(backward); // ['D', 'C', 'B', 'A'];
|
|
891
442
|
*/
|
|
892
443
|
/**
|
|
893
444
|
* Find the last value matching a predicate (scans back-to-front).
|
|
894
445
|
* @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1).
|
|
895
446
|
* @param predicate - Function called with (value, index, deque).
|
|
896
447
|
* @returns Matching value or undefined.
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
448
|
+
* @example
|
|
449
|
+
* // Find last matching value
|
|
450
|
+
* const d = new Deque([1, 2, 3, 4, 5]);
|
|
451
|
+
* console.log(d.findLast(v => v > 2)); // 5;
|
|
452
|
+
* console.log(d.findLast(v => v % 2 === 0)); // 4;
|
|
902
453
|
*/
|
|
903
454
|
findLast(predicate: (value: E, index: number, deque: this) => boolean): E | undefined;
|
|
904
455
|
/**
|
|
@@ -906,36 +457,34 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
|
|
|
906
457
|
* @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1).
|
|
907
458
|
* @param predicate - Function called with (value, index, deque).
|
|
908
459
|
* @returns Matching index, or -1 if not found.
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
460
|
+
* @example
|
|
461
|
+
* // Find last matching index
|
|
462
|
+
* const d = new Deque([10, 20, 30, 20, 10]);
|
|
463
|
+
* console.log(d.findLastIndex(v => v === 20)); // 3;
|
|
464
|
+
* console.log(d.findLastIndex(v => v === 10)); // 4;
|
|
914
465
|
*/
|
|
915
466
|
findLastIndex(predicate: (value: E, index: number, deque: this) => boolean): number;
|
|
916
467
|
/**
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
* console.log(backward); // ['D', 'C', 'B', 'A'];
|
|
938
|
-
*/
|
|
468
|
+
* Deque for...of iteration and reverse
|
|
469
|
+
* @example
|
|
470
|
+
* // Deque for...of iteration and reverse
|
|
471
|
+
* const deque = new Deque<string>(['A', 'B', 'C', 'D']);
|
|
472
|
+
*
|
|
473
|
+
* // Iterate forward
|
|
474
|
+
* const forward: string[] = [];
|
|
475
|
+
* for (const item of deque) {
|
|
476
|
+
* forward.push(item);
|
|
477
|
+
* }
|
|
478
|
+
* console.log(forward); // ['A', 'B', 'C', 'D'];
|
|
479
|
+
*
|
|
480
|
+
* // Reverse the deque
|
|
481
|
+
* deque.reverse();
|
|
482
|
+
* const backward: string[] = [];
|
|
483
|
+
* for (const item of deque) {
|
|
484
|
+
* backward.push(item);
|
|
485
|
+
* }
|
|
486
|
+
* console.log(backward); // ['D', 'C', 'B', 'A'];
|
|
487
|
+
*/
|
|
939
488
|
reverse(): this;
|
|
940
489
|
/**
|
|
941
490
|
* Deduplicate consecutive equal elements in-place.
|
|
@@ -943,17 +492,6 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
|
|
|
943
492
|
* @returns This deque.
|
|
944
493
|
*/
|
|
945
494
|
unique(): this;
|
|
946
|
-
/**
|
|
947
|
-
* Trim unused buckets to fit exactly the active range.
|
|
948
|
-
* @remarks Time O(N), Space O(1)
|
|
949
|
-
* @returns void
|
|
950
|
-
*/
|
|
951
|
-
/**
|
|
952
|
-
* (Protected) Trigger auto-compaction if space utilization drops below threshold.
|
|
953
|
-
* Only checks every `_bucketSize` operations to minimize hot-path overhead.
|
|
954
|
-
* Uses element-based ratio: `elements / (bucketCount * bucketSize)`.
|
|
955
|
-
*/
|
|
956
|
-
protected _autoCompact(): void;
|
|
957
495
|
/**
|
|
958
496
|
* Compact the deque by removing unused buckets.
|
|
959
497
|
* @remarks Time O(N), Space O(1)
|
|
@@ -963,52 +501,13 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
|
|
|
963
501
|
* Compact the deque by removing unused buckets.
|
|
964
502
|
* @remarks Time O(N), Space O(1)
|
|
965
503
|
* @returns True if compaction was performed (bucket count reduced).
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
* @example
|
|
1006
|
-
* // Reclaim memory
|
|
1007
|
-
* const dq = new Deque<number>([1, 2, 3, 4, 5]);
|
|
1008
|
-
* dq.shift();
|
|
1009
|
-
* dq.shift();
|
|
1010
|
-
* dq.compact();
|
|
1011
|
-
* console.log(dq.length); // 3;
|
|
504
|
+
* @example
|
|
505
|
+
* // Reclaim memory
|
|
506
|
+
* const dq = new Deque<number>([1, 2, 3, 4, 5]);
|
|
507
|
+
* dq.shift();
|
|
508
|
+
* dq.shift();
|
|
509
|
+
* dq.compact();
|
|
510
|
+
* console.log(dq.length); // 3;
|
|
1012
511
|
*/
|
|
1013
512
|
compact(): boolean;
|
|
1014
513
|
shrinkToFit(): void;
|
|
@@ -1016,53 +515,13 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
|
|
|
1016
515
|
* Deep clone this deque, preserving options.
|
|
1017
516
|
* @remarks Time O(N), Space O(N)
|
|
1018
517
|
* @returns A new deque with the same content and options.
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
* @example
|
|
1060
|
-
* // Create independent copy
|
|
1061
|
-
* const dq = new Deque<number>([1, 2, 3]);
|
|
1062
|
-
* const copy = dq.clone();
|
|
1063
|
-
* copy.pop();
|
|
1064
|
-
* console.log(dq.length); // 3;
|
|
1065
|
-
* console.log(copy.length); // 2;
|
|
518
|
+
* @example
|
|
519
|
+
* // Create independent copy
|
|
520
|
+
* const dq = new Deque<number>([1, 2, 3]);
|
|
521
|
+
* const copy = dq.clone();
|
|
522
|
+
* copy.pop();
|
|
523
|
+
* console.log(dq.length); // 3;
|
|
524
|
+
* console.log(copy.length); // 2;
|
|
1066
525
|
*/
|
|
1067
526
|
clone(): this;
|
|
1068
527
|
/**
|
|
@@ -1071,51 +530,11 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
|
|
|
1071
530
|
* @param predicate - Predicate (value, index, deque) → boolean to keep element.
|
|
1072
531
|
* @param [thisArg] - Value for `this` inside the predicate.
|
|
1073
532
|
* @returns A new deque with kept elements.
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
* @example
|
|
1115
|
-
* // Filter elements
|
|
1116
|
-
* const dq = new Deque<number>([1, 2, 3, 4]);
|
|
1117
|
-
* const result = dq.filter(x => x > 2);
|
|
1118
|
-
* console.log(result.length); // 2;
|
|
533
|
+
* @example
|
|
534
|
+
* // Filter elements
|
|
535
|
+
* const dq = new Deque<number>([1, 2, 3, 4]);
|
|
536
|
+
* const result = dq.filter(x => x > 2);
|
|
537
|
+
* console.log(result.length); // 2;
|
|
1119
538
|
*/
|
|
1120
539
|
filter(predicate: ElementCallback<E, R, boolean>, thisArg?: unknown): this;
|
|
1121
540
|
/**
|
|
@@ -1135,52 +554,25 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
|
|
|
1135
554
|
* @param [options] - Options for the output deque (e.g., bucketSize, toElementFn, maxLen).
|
|
1136
555
|
* @param [thisArg] - Value for `this` inside the callback.
|
|
1137
556
|
* @returns A new Deque with mapped elements.
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
* @example
|
|
1178
|
-
* // Transform elements
|
|
1179
|
-
* const dq = new Deque<number>([1, 2, 3]);
|
|
1180
|
-
* const result = dq.map(x => x * 10);
|
|
1181
|
-
* console.log(result.toArray()); // [10, 20, 30];
|
|
557
|
+
* @example
|
|
558
|
+
* // Transform elements
|
|
559
|
+
* const dq = new Deque<number>([1, 2, 3]);
|
|
560
|
+
* const result = dq.map(x => x * 10);
|
|
561
|
+
* console.log(result.toArray()); // [10, 20, 30];
|
|
1182
562
|
*/
|
|
1183
563
|
map<EM, RM>(callback: ElementCallback<E, R, EM>, options?: IterableElementBaseOptions<EM, RM>, thisArg?: unknown): Deque<EM, RM>;
|
|
564
|
+
protected _equals: (a: E, b: E) => boolean;
|
|
565
|
+
/**
|
|
566
|
+
* Trim unused buckets to fit exactly the active range.
|
|
567
|
+
* @remarks Time O(N), Space O(1)
|
|
568
|
+
* @returns void
|
|
569
|
+
*/
|
|
570
|
+
/**
|
|
571
|
+
* (Protected) Trigger auto-compaction if space utilization drops below threshold.
|
|
572
|
+
* Only checks every `_bucketSize` operations to minimize hot-path overhead.
|
|
573
|
+
* Uses element-based ratio: `elements / (bucketCount * bucketSize)`.
|
|
574
|
+
*/
|
|
575
|
+
protected _autoCompact(): void;
|
|
1184
576
|
/**
|
|
1185
577
|
* (Protected) Set the internal bucket size.
|
|
1186
578
|
* @remarks Time O(1), Space O(1)
|