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
|
@@ -121,7 +121,6 @@ export declare class DoublyLinkedListNode<E = any> extends LinkedListNode<E> {
|
|
|
121
121
|
* console.log(sum); // [1, 2, 3];
|
|
122
122
|
*/
|
|
123
123
|
export declare class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, DoublyLinkedListNode<E>> {
|
|
124
|
-
protected _equals: (a: E, b: E) => boolean;
|
|
125
124
|
/**
|
|
126
125
|
* Create a DoublyLinkedList and optionally bulk-insert elements.
|
|
127
126
|
* @remarks Time O(N), Space O(N)
|
|
@@ -185,179 +184,53 @@ export declare class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase
|
|
|
185
184
|
* @remarks Time O(1), Space O(1)
|
|
186
185
|
* @param elementOrNode - Element or node to append.
|
|
187
186
|
* @returns True when appended.
|
|
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
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
* @example
|
|
231
|
-
* // basic DoublyLinkedList creation and push operation
|
|
232
|
-
* // Create a simple DoublyLinkedList with initial values
|
|
233
|
-
* const list = new DoublyLinkedList([1, 2, 3, 4, 5]);
|
|
234
|
-
*
|
|
235
|
-
* // Verify the list maintains insertion order
|
|
236
|
-
* console.log([...list]); // [1, 2, 3, 4, 5];
|
|
237
|
-
*
|
|
238
|
-
* // Check length
|
|
239
|
-
* console.log(list.length); // 5;
|
|
240
|
-
*
|
|
241
|
-
* // Push a new element to the end
|
|
242
|
-
* list.push(6);
|
|
243
|
-
* console.log(list.length); // 6;
|
|
244
|
-
* console.log([...list]); // [1, 2, 3, 4, 5, 6];
|
|
187
|
+
* @example
|
|
188
|
+
* // basic DoublyLinkedList creation and push operation
|
|
189
|
+
* // Create a simple DoublyLinkedList with initial values
|
|
190
|
+
* const list = new DoublyLinkedList([1, 2, 3, 4, 5]);
|
|
191
|
+
*
|
|
192
|
+
* // Verify the list maintains insertion order
|
|
193
|
+
* console.log([...list]); // [1, 2, 3, 4, 5];
|
|
194
|
+
*
|
|
195
|
+
* // Check length
|
|
196
|
+
* console.log(list.length); // 5;
|
|
197
|
+
*
|
|
198
|
+
* // Push a new element to the end
|
|
199
|
+
* list.push(6);
|
|
200
|
+
* console.log(list.length); // 6;
|
|
201
|
+
* console.log([...list]); // [1, 2, 3, 4, 5, 6];
|
|
245
202
|
*/
|
|
246
203
|
push(elementOrNode: E | DoublyLinkedListNode<E>): boolean;
|
|
247
204
|
/**
|
|
248
205
|
* Remove and return the tail element.
|
|
249
206
|
* @remarks Time O(1), Space O(1)
|
|
250
207
|
* @returns Removed element or undefined.
|
|
251
|
-
|
|
252
|
-
|
|
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
|
-
* @example
|
|
294
|
-
* // DoublyLinkedList pop and shift operations
|
|
295
|
-
* const list = new DoublyLinkedList<number>([10, 20, 30, 40, 50]);
|
|
296
|
-
*
|
|
297
|
-
* // Pop removes from the end
|
|
298
|
-
* const last = list.pop();
|
|
299
|
-
* console.log(last); // 50;
|
|
300
|
-
*
|
|
301
|
-
* // Shift removes from the beginning
|
|
302
|
-
* const first = list.shift();
|
|
303
|
-
* console.log(first); // 10;
|
|
304
|
-
*
|
|
305
|
-
* // Verify remaining elements
|
|
306
|
-
* console.log([...list]); // [20, 30, 40];
|
|
307
|
-
* console.log(list.length); // 3;
|
|
208
|
+
* @example
|
|
209
|
+
* // DoublyLinkedList pop and shift operations
|
|
210
|
+
* const list = new DoublyLinkedList<number>([10, 20, 30, 40, 50]);
|
|
211
|
+
*
|
|
212
|
+
* // Pop removes from the end
|
|
213
|
+
* const last = list.pop();
|
|
214
|
+
* console.log(last); // 50;
|
|
215
|
+
*
|
|
216
|
+
* // Shift removes from the beginning
|
|
217
|
+
* const first = list.shift();
|
|
218
|
+
* console.log(first); // 10;
|
|
219
|
+
*
|
|
220
|
+
* // Verify remaining elements
|
|
221
|
+
* console.log([...list]); // [20, 30, 40];
|
|
222
|
+
* console.log(list.length); // 3;
|
|
308
223
|
*/
|
|
309
224
|
pop(): E | undefined;
|
|
310
225
|
/**
|
|
311
226
|
* Remove and return the head element.
|
|
312
227
|
* @remarks Time O(1), Space O(1)
|
|
313
228
|
* @returns Removed element or undefined.
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
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
|
-
* @example
|
|
357
|
-
* // Remove from the front
|
|
358
|
-
* const list = new DoublyLinkedList<number>([10, 20, 30]);
|
|
359
|
-
* console.log(list.shift()); // 10;
|
|
360
|
-
* console.log(list.first); // 20;
|
|
229
|
+
* @example
|
|
230
|
+
* // Remove from the front
|
|
231
|
+
* const list = new DoublyLinkedList<number>([10, 20, 30]);
|
|
232
|
+
* console.log(list.shift()); // 10;
|
|
233
|
+
* console.log(list.first); // 20;
|
|
361
234
|
*/
|
|
362
235
|
shift(): E | undefined;
|
|
363
236
|
/**
|
|
@@ -365,53 +238,11 @@ export declare class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase
|
|
|
365
238
|
* @remarks Time O(1), Space O(1)
|
|
366
239
|
* @param elementOrNode - Element or node to prepend.
|
|
367
240
|
* @returns True when prepended.
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
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
|
-
* @example
|
|
411
|
-
* // Add to the front
|
|
412
|
-
* const list = new DoublyLinkedList<number>([2, 3]);
|
|
413
|
-
* list.unshift(1);
|
|
414
|
-
* console.log([...list]); // [1, 2, 3];
|
|
241
|
+
* @example
|
|
242
|
+
* // Add to the front
|
|
243
|
+
* const list = new DoublyLinkedList<number>([2, 3]);
|
|
244
|
+
* list.unshift(1);
|
|
245
|
+
* console.log([...list]); // [1, 2, 3];
|
|
415
246
|
*/
|
|
416
247
|
unshift(elementOrNode: E | DoublyLinkedListNode<E>): boolean;
|
|
417
248
|
/**
|
|
@@ -433,53 +264,11 @@ export declare class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase
|
|
|
433
264
|
* @remarks Time O(N), Space O(1)
|
|
434
265
|
* @param index - Zero-based index.
|
|
435
266
|
* @returns Element or undefined.
|
|
436
|
-
|
|
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
|
-
* @example
|
|
479
|
-
* // Access by index
|
|
480
|
-
* const list = new DoublyLinkedList<string>(['a', 'b', 'c']);
|
|
481
|
-
* console.log(list.at(1)); // 'b';
|
|
482
|
-
* console.log(list.at(2)); // 'c';
|
|
267
|
+
* @example
|
|
268
|
+
* // Access by index
|
|
269
|
+
* const list = new DoublyLinkedList<string>(['a', 'b', 'c']);
|
|
270
|
+
* console.log(list.at(1)); // 'b';
|
|
271
|
+
* console.log(list.at(2)); // 'c';
|
|
483
272
|
*/
|
|
484
273
|
at(index: number): E | undefined;
|
|
485
274
|
/**
|
|
@@ -487,49 +276,10 @@ export declare class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase
|
|
|
487
276
|
* @remarks Time O(N), Space O(1)
|
|
488
277
|
* @param index - Zero-based index.
|
|
489
278
|
* @returns Node or undefined.
|
|
490
|
-
|
|
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
|
-
* @example
|
|
530
|
-
* // Get node at index
|
|
531
|
-
* const list = new DoublyLinkedList<string>(['a', 'b', 'c']);
|
|
532
|
-
* console.log(list.getNodeAt(1)?.value); // 'b';
|
|
279
|
+
* @example
|
|
280
|
+
* // Get node at index
|
|
281
|
+
* const list = new DoublyLinkedList<string>(['a', 'b', 'c']);
|
|
282
|
+
* console.log(list.getNodeAt(1)?.value); // 'b';
|
|
533
283
|
*/
|
|
534
284
|
getNodeAt(index: number): DoublyLinkedListNode<E> | undefined;
|
|
535
285
|
/**
|
|
@@ -545,50 +295,11 @@ export declare class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase
|
|
|
545
295
|
* @param index - Zero-based index.
|
|
546
296
|
* @param newElementOrNode - Element or node to insert.
|
|
547
297
|
* @returns True if inserted.
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
* @example
|
|
588
|
-
* // Insert at position
|
|
589
|
-
* const list = new DoublyLinkedList<number>([1, 3]);
|
|
590
|
-
* list.addAt(1, 2);
|
|
591
|
-
* console.log(list.toArray()); // [1, 2, 3];
|
|
298
|
+
* @example
|
|
299
|
+
* // Insert at position
|
|
300
|
+
* const list = new DoublyLinkedList<number>([1, 3]);
|
|
301
|
+
* list.addAt(1, 2);
|
|
302
|
+
* console.log(list.toArray()); // [1, 2, 3];
|
|
592
303
|
*/
|
|
593
304
|
addAt(index: number, newElementOrNode: E | DoublyLinkedListNode<E>): boolean;
|
|
594
305
|
/**
|
|
@@ -620,50 +331,11 @@ export declare class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase
|
|
|
620
331
|
* @remarks Time O(N), Space O(1)
|
|
621
332
|
* @param index - Zero-based index.
|
|
622
333
|
* @returns Removed element or undefined.
|
|
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
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
* @example
|
|
663
|
-
* // Remove by index
|
|
664
|
-
* const list = new DoublyLinkedList<string>(['a', 'b', 'c']);
|
|
665
|
-
* list.deleteAt(1);
|
|
666
|
-
* console.log(list.toArray()); // ['a', 'c'];
|
|
334
|
+
* @example
|
|
335
|
+
* // Remove by index
|
|
336
|
+
* const list = new DoublyLinkedList<string>(['a', 'b', 'c']);
|
|
337
|
+
* list.deleteAt(1);
|
|
338
|
+
* console.log(list.toArray()); // ['a', 'c'];
|
|
667
339
|
*/
|
|
668
340
|
deleteAt(index: number): E | undefined;
|
|
669
341
|
/**
|
|
@@ -671,150 +343,31 @@ export declare class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase
|
|
|
671
343
|
* @remarks Time O(N), Space O(1)
|
|
672
344
|
* @param [elementOrNode] - Element or node to remove.
|
|
673
345
|
* @returns True if removed.
|
|
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
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
* @example
|
|
714
|
-
* // Remove first occurrence
|
|
715
|
-
* const list = new DoublyLinkedList<number>([1, 2, 3, 2]);
|
|
716
|
-
* list.delete(2);
|
|
717
|
-
* console.log(list.toArray()); // [1, 3, 2];
|
|
346
|
+
* @example
|
|
347
|
+
* // Remove first occurrence
|
|
348
|
+
* const list = new DoublyLinkedList<number>([1, 2, 3, 2]);
|
|
349
|
+
* list.delete(2);
|
|
350
|
+
* console.log(list.toArray()); // [1, 3, 2];
|
|
718
351
|
*/
|
|
719
352
|
delete(elementOrNode: E | DoublyLinkedListNode<E> | undefined): boolean;
|
|
720
353
|
/**
|
|
721
354
|
* Check whether the list is empty.
|
|
722
355
|
* @remarks Time O(1), Space O(1)
|
|
723
356
|
* @returns True if length is 0.
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
* @example
|
|
765
|
-
* // Check empty
|
|
766
|
-
* console.log(new DoublyLinkedList().isEmpty()); // true;
|
|
357
|
+
* @example
|
|
358
|
+
* // Check empty
|
|
359
|
+
* console.log(new DoublyLinkedList().isEmpty()); // true;
|
|
767
360
|
*/
|
|
768
361
|
isEmpty(): boolean;
|
|
769
362
|
/**
|
|
770
363
|
* Remove all nodes and reset length.
|
|
771
364
|
* @remarks Time O(N), Space O(1)
|
|
772
365
|
* @returns void
|
|
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
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
* @example
|
|
814
|
-
* // Remove all
|
|
815
|
-
* const list = new DoublyLinkedList<number>([1, 2]);
|
|
816
|
-
* list.clear();
|
|
817
|
-
* console.log(list.isEmpty()); // true;
|
|
366
|
+
* @example
|
|
367
|
+
* // Remove all
|
|
368
|
+
* const list = new DoublyLinkedList<number>([1, 2]);
|
|
369
|
+
* list.clear();
|
|
370
|
+
* console.log(list.isEmpty()); // true;
|
|
818
371
|
*/
|
|
819
372
|
clear(): void;
|
|
820
373
|
/**
|
|
@@ -822,50 +375,11 @@ export declare class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase
|
|
|
822
375
|
* @remarks Time O(N), Space O(1)
|
|
823
376
|
* @param elementNodeOrPredicate - Element, node, or predicate to match.
|
|
824
377
|
* @returns Matched value or undefined.
|
|
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
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
* @example
|
|
865
|
-
* // Search with predicate
|
|
866
|
-
* const list = new DoublyLinkedList<number>([10, 20, 30]);
|
|
867
|
-
* const found = list.search(node => node.value > 15);
|
|
868
|
-
* console.log(found); // 20;
|
|
378
|
+
* @example
|
|
379
|
+
* // Search with predicate
|
|
380
|
+
* const list = new DoublyLinkedList<number>([10, 20, 30]);
|
|
381
|
+
* const found = list.search(node => node.value > 15);
|
|
382
|
+
* console.log(found); // 20;
|
|
869
383
|
*/
|
|
870
384
|
search(elementNodeOrPredicate: E | DoublyLinkedListNode<E> | ((node: DoublyLinkedListNode<E>) => boolean)): E | undefined;
|
|
871
385
|
/**
|
|
@@ -873,48 +387,12 @@ export declare class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase
|
|
|
873
387
|
* @remarks Time O(N), Space O(1)
|
|
874
388
|
* @param elementNodeOrPredicate - Element, node, or predicate to match.
|
|
875
389
|
* @returns Matched value or undefined.
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
* @example
|
|
913
|
-
* // Find value scanning from tail
|
|
914
|
-
* const list = new DoublyLinkedList<number>([1, 2, 3, 4]);
|
|
915
|
-
* // findLast scans from tail to head, returns first match
|
|
916
|
-
* const found = list.findLast(node => node.value < 4);
|
|
917
|
-
* console.log(found); // 3;
|
|
390
|
+
* @example
|
|
391
|
+
* // Find value scanning from tail
|
|
392
|
+
* const list = new DoublyLinkedList<number>([1, 2, 3, 4]);
|
|
393
|
+
* // findLast scans from tail to head, returns first match
|
|
394
|
+
* const found = list.findLast(node => node.value < 4);
|
|
395
|
+
* console.log(found); // 3;
|
|
918
396
|
*/
|
|
919
397
|
/**
|
|
920
398
|
* @deprecated Use `findLast` instead. Will be removed in a future major version.
|
|
@@ -925,14 +403,12 @@ export declare class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase
|
|
|
925
403
|
* @remarks Time O(N), Space O(1)
|
|
926
404
|
* @param elementNodeOrPredicate - Element, node, or predicate to match.
|
|
927
405
|
* @returns Matching value or undefined.
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
* const found = list.findLast(node => node.value < 4);
|
|
935
|
-
* console.log(found); // 3;
|
|
406
|
+
* @example
|
|
407
|
+
* // Find value scanning from tail
|
|
408
|
+
* const list = new DoublyLinkedList<number>([1, 2, 3, 4]);
|
|
409
|
+
* // findLast scans from tail to head, returns first match
|
|
410
|
+
* const found = list.findLast(node => node.value < 4);
|
|
411
|
+
* console.log(found); // 3;
|
|
936
412
|
*/
|
|
937
413
|
findLast(elementNodeOrPredicate: E | DoublyLinkedListNode<E> | ((node: DoublyLinkedListNode<E>) => boolean)): E | undefined;
|
|
938
414
|
/**
|
|
@@ -946,53 +422,11 @@ export declare class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase
|
|
|
946
422
|
* Reverse the list in place.
|
|
947
423
|
* @remarks Time O(N), Space O(1)
|
|
948
424
|
* @returns This list.
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
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
|
-
* @example
|
|
992
|
-
* // Reverse in-place
|
|
993
|
-
* const list = new DoublyLinkedList<number>([1, 2, 3]);
|
|
994
|
-
* list.reverse();
|
|
995
|
-
* console.log([...list]); // [3, 2, 1];
|
|
425
|
+
* @example
|
|
426
|
+
* // Reverse in-place
|
|
427
|
+
* const list = new DoublyLinkedList<number>([1, 2, 3]);
|
|
428
|
+
* list.reverse();
|
|
429
|
+
* console.log([...list]); // [3, 2, 1];
|
|
996
430
|
*/
|
|
997
431
|
reverse(): this;
|
|
998
432
|
/**
|
|
@@ -1013,52 +447,12 @@ export declare class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase
|
|
|
1013
447
|
* Deep clone this list (values are copied by reference).
|
|
1014
448
|
* @remarks Time O(N), Space O(N)
|
|
1015
449
|
* @returns A new list with the same element sequence.
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
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
|
-
* @example
|
|
1057
|
-
* // Deep copy
|
|
1058
|
-
* const list = new DoublyLinkedList<number>([1, 2, 3]);
|
|
1059
|
-
* const copy = list.clone();
|
|
1060
|
-
* copy.pop();
|
|
1061
|
-
* console.log(list.length); // 3;
|
|
450
|
+
* @example
|
|
451
|
+
* // Deep copy
|
|
452
|
+
* const list = new DoublyLinkedList<number>([1, 2, 3]);
|
|
453
|
+
* const copy = list.clone();
|
|
454
|
+
* copy.pop();
|
|
455
|
+
* console.log(list.length); // 3;
|
|
1062
456
|
*/
|
|
1063
457
|
clone(): this;
|
|
1064
458
|
/**
|
|
@@ -1067,53 +461,11 @@ export declare class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase
|
|
|
1067
461
|
* @param callback - Predicate (value, index, list) → boolean to keep value.
|
|
1068
462
|
* @param [thisArg] - Value for `this` inside the callback.
|
|
1069
463
|
* @returns A new list with kept values.
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
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
|
-
* @example
|
|
1113
|
-
* // Filter elements
|
|
1114
|
-
* const list = new DoublyLinkedList<number>([1, 2, 3, 4, 5]);
|
|
1115
|
-
* const evens = list.filter(n => n % 2 === 0);
|
|
1116
|
-
* console.log([...evens]); // [2, 4];
|
|
464
|
+
* @example
|
|
465
|
+
* // Filter elements
|
|
466
|
+
* const list = new DoublyLinkedList<number>([1, 2, 3, 4, 5]);
|
|
467
|
+
* const evens = list.filter(n => n % 2 === 0);
|
|
468
|
+
* console.log([...evens]); // [2, 4];
|
|
1117
469
|
*/
|
|
1118
470
|
filter(callback: ElementCallback<E, R, boolean>, thisArg?: unknown): this;
|
|
1119
471
|
/**
|
|
@@ -1133,64 +485,23 @@ export declare class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase
|
|
|
1133
485
|
* @param [options] - Options for the output list (e.g., maxLen, toElementFn).
|
|
1134
486
|
* @param [thisArg] - Value for `this` inside the callback.
|
|
1135
487
|
* @returns A new DoublyLinkedList with mapped values.
|
|
1136
|
-
|
|
1137
|
-
|
|
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
|
-
|
|
1178
|
-
* @example
|
|
1179
|
-
* // DoublyLinkedList for...of iteration and map operation
|
|
1180
|
-
* const list = new DoublyLinkedList<number>([1, 2, 3, 4, 5]);
|
|
1181
|
-
*
|
|
1182
|
-
* // Iterate through list
|
|
1183
|
-
* const doubled = list.map(value => value * 2);
|
|
1184
|
-
* console.log(doubled.length); // 5;
|
|
1185
|
-
*
|
|
1186
|
-
* // Use for...of loop
|
|
1187
|
-
* const result: number[] = [];
|
|
1188
|
-
* for (const item of list) {
|
|
1189
|
-
* result.push(item);
|
|
1190
|
-
* }
|
|
1191
|
-
* console.log(result); // [1, 2, 3, 4, 5];
|
|
488
|
+
* @example
|
|
489
|
+
* // DoublyLinkedList for...of iteration and map operation
|
|
490
|
+
* const list = new DoublyLinkedList<number>([1, 2, 3, 4, 5]);
|
|
491
|
+
*
|
|
492
|
+
* // Iterate through list
|
|
493
|
+
* const doubled = list.map(value => value * 2);
|
|
494
|
+
* console.log(doubled.length); // 5;
|
|
495
|
+
*
|
|
496
|
+
* // Use for...of loop
|
|
497
|
+
* const result: number[] = [];
|
|
498
|
+
* for (const item of list) {
|
|
499
|
+
* result.push(item);
|
|
500
|
+
* }
|
|
501
|
+
* console.log(result); // [1, 2, 3, 4, 5];
|
|
1192
502
|
*/
|
|
1193
503
|
map<EM, RM>(callback: ElementCallback<E, R, EM>, options?: DoublyLinkedListOptions<EM, RM>, thisArg?: unknown): DoublyLinkedList<EM, RM>;
|
|
504
|
+
protected _equals: (a: E, b: E) => boolean;
|
|
1194
505
|
/**
|
|
1195
506
|
* (Protected) Create or return a node for the given input (node or raw element).
|
|
1196
507
|
* @remarks Time O(1), Space O(1)
|