binary-tree-typed 2.5.2 → 2.5.3
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/dist/cjs/index.cjs +194 -55
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs-legacy/index.cjs +194 -55
- package/dist/cjs-legacy/index.cjs.map +1 -1
- package/dist/esm/index.mjs +194 -55
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm-legacy/index.mjs +194 -55
- package/dist/esm-legacy/index.mjs.map +1 -1
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +50 -2
- package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +56 -0
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +116 -15
- package/dist/types/data-structures/binary-tree/bst.d.ts +99 -3
- package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +79 -8
- package/dist/types/data-structures/binary-tree/segment-tree.d.ts +24 -0
- package/dist/types/data-structures/binary-tree/tree-map.d.ts +520 -1
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +489 -1
- package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +393 -1
- package/dist/types/data-structures/binary-tree/tree-set.d.ts +500 -1
- package/dist/types/data-structures/graph/directed-graph.d.ts +40 -0
- package/dist/types/data-structures/graph/undirected-graph.d.ts +36 -0
- package/dist/types/data-structures/hash/hash-map.d.ts +51 -6
- package/dist/types/data-structures/heap/heap.d.ts +98 -12
- package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +75 -0
- package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +61 -1
- package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +72 -0
- package/dist/types/data-structures/matrix/matrix.d.ts +32 -0
- package/dist/types/data-structures/queue/deque.d.ts +82 -0
- package/dist/types/data-structures/queue/queue.d.ts +61 -0
- package/dist/types/data-structures/stack/stack.d.ts +42 -2
- package/dist/types/data-structures/trie/trie.d.ts +48 -0
- package/dist/types/interfaces/binary-tree.d.ts +2 -3
- package/dist/umd/binary-tree-typed.js +194 -55
- package/dist/umd/binary-tree-typed.js.map +1 -1
- package/dist/umd/binary-tree-typed.min.js +5 -5
- package/dist/umd/binary-tree-typed.min.js.map +1 -1
- package/package.json +2 -2
- package/src/data-structures/binary-tree/avl-tree.ts +52 -5
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +56 -0
- package/src/data-structures/binary-tree/binary-tree.ts +167 -81
- package/src/data-structures/binary-tree/bst.ts +101 -7
- package/src/data-structures/binary-tree/red-black-tree.ts +82 -15
- package/src/data-structures/binary-tree/segment-tree.ts +24 -0
- package/src/data-structures/binary-tree/tree-map.ts +540 -3
- package/src/data-structures/binary-tree/tree-multi-map.ts +490 -2
- package/src/data-structures/binary-tree/tree-multi-set.ts +393 -1
- package/src/data-structures/binary-tree/tree-set.ts +520 -3
- package/src/data-structures/graph/directed-graph.ts +41 -1
- package/src/data-structures/graph/undirected-graph.ts +37 -1
- package/src/data-structures/hash/hash-map.ts +67 -12
- package/src/data-structures/heap/heap.ts +107 -19
- package/src/data-structures/linked-list/doubly-linked-list.ts +88 -0
- package/src/data-structures/linked-list/singly-linked-list.ts +61 -1
- package/src/data-structures/linked-list/skip-linked-list.ts +72 -0
- package/src/data-structures/matrix/matrix.ts +32 -0
- package/src/data-structures/queue/deque.ts +85 -0
- package/src/data-structures/queue/queue.ts +73 -0
- package/src/data-structures/stack/stack.ts +45 -5
- package/src/data-structures/trie/trie.ts +48 -0
- package/src/interfaces/binary-tree.ts +1 -9
|
@@ -184,6 +184,10 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
|
|
|
184
184
|
|
|
185
185
|
|
|
186
186
|
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
|
|
187
191
|
|
|
188
192
|
|
|
189
193
|
|
|
@@ -243,6 +247,10 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
|
|
|
243
247
|
|
|
244
248
|
|
|
245
249
|
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
|
|
246
254
|
|
|
247
255
|
|
|
248
256
|
|
|
@@ -304,6 +312,10 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
|
|
|
304
312
|
|
|
305
313
|
|
|
306
314
|
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
|
|
307
319
|
|
|
308
320
|
|
|
309
321
|
|
|
@@ -353,6 +365,10 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
|
|
|
353
365
|
|
|
354
366
|
|
|
355
367
|
|
|
368
|
+
|
|
369
|
+
|
|
370
|
+
|
|
371
|
+
|
|
356
372
|
|
|
357
373
|
|
|
358
374
|
|
|
@@ -401,6 +417,10 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
|
|
|
401
417
|
|
|
402
418
|
|
|
403
419
|
|
|
420
|
+
|
|
421
|
+
|
|
422
|
+
|
|
423
|
+
|
|
404
424
|
|
|
405
425
|
|
|
406
426
|
|
|
@@ -477,6 +497,10 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
|
|
|
477
497
|
|
|
478
498
|
|
|
479
499
|
|
|
500
|
+
|
|
501
|
+
|
|
502
|
+
|
|
503
|
+
|
|
480
504
|
|
|
481
505
|
|
|
482
506
|
|
|
@@ -535,6 +559,10 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
|
|
|
535
559
|
|
|
536
560
|
|
|
537
561
|
|
|
562
|
+
|
|
563
|
+
|
|
564
|
+
|
|
565
|
+
|
|
538
566
|
|
|
539
567
|
|
|
540
568
|
|
|
@@ -579,6 +607,10 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
|
|
|
579
607
|
|
|
580
608
|
|
|
581
609
|
|
|
610
|
+
|
|
611
|
+
|
|
612
|
+
|
|
613
|
+
|
|
582
614
|
|
|
583
615
|
|
|
584
616
|
|
|
@@ -650,6 +682,10 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
|
|
|
650
682
|
|
|
651
683
|
|
|
652
684
|
|
|
685
|
+
|
|
686
|
+
|
|
687
|
+
|
|
688
|
+
|
|
653
689
|
|
|
654
690
|
|
|
655
691
|
|
|
@@ -717,6 +753,10 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
|
|
|
717
753
|
|
|
718
754
|
|
|
719
755
|
|
|
756
|
+
|
|
757
|
+
|
|
758
|
+
|
|
759
|
+
|
|
720
760
|
|
|
721
761
|
|
|
722
762
|
|
|
@@ -201,6 +201,10 @@ export declare class UndirectedGraph<V = any, E = any, VO extends UndirectedVert
|
|
|
201
201
|
|
|
202
202
|
|
|
203
203
|
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
|
|
204
208
|
|
|
205
209
|
|
|
206
210
|
|
|
@@ -259,6 +263,10 @@ export declare class UndirectedGraph<V = any, E = any, VO extends UndirectedVert
|
|
|
259
263
|
|
|
260
264
|
|
|
261
265
|
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
|
|
262
270
|
|
|
263
271
|
|
|
264
272
|
|
|
@@ -325,6 +333,10 @@ export declare class UndirectedGraph<V = any, E = any, VO extends UndirectedVert
|
|
|
325
333
|
|
|
326
334
|
|
|
327
335
|
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
|
|
328
340
|
|
|
329
341
|
|
|
330
342
|
|
|
@@ -385,6 +397,10 @@ export declare class UndirectedGraph<V = any, E = any, VO extends UndirectedVert
|
|
|
385
397
|
|
|
386
398
|
|
|
387
399
|
|
|
400
|
+
|
|
401
|
+
|
|
402
|
+
|
|
403
|
+
|
|
388
404
|
|
|
389
405
|
|
|
390
406
|
|
|
@@ -431,6 +447,10 @@ export declare class UndirectedGraph<V = any, E = any, VO extends UndirectedVert
|
|
|
431
447
|
|
|
432
448
|
|
|
433
449
|
|
|
450
|
+
|
|
451
|
+
|
|
452
|
+
|
|
453
|
+
|
|
434
454
|
|
|
435
455
|
|
|
436
456
|
|
|
@@ -524,6 +544,10 @@ export declare class UndirectedGraph<V = any, E = any, VO extends UndirectedVert
|
|
|
524
544
|
|
|
525
545
|
|
|
526
546
|
|
|
547
|
+
|
|
548
|
+
|
|
549
|
+
|
|
550
|
+
|
|
527
551
|
|
|
528
552
|
|
|
529
553
|
|
|
@@ -585,6 +609,10 @@ export declare class UndirectedGraph<V = any, E = any, VO extends UndirectedVert
|
|
|
585
609
|
|
|
586
610
|
|
|
587
611
|
|
|
612
|
+
|
|
613
|
+
|
|
614
|
+
|
|
615
|
+
|
|
588
616
|
|
|
589
617
|
|
|
590
618
|
|
|
@@ -634,6 +662,10 @@ export declare class UndirectedGraph<V = any, E = any, VO extends UndirectedVert
|
|
|
634
662
|
|
|
635
663
|
|
|
636
664
|
|
|
665
|
+
|
|
666
|
+
|
|
667
|
+
|
|
668
|
+
|
|
637
669
|
|
|
638
670
|
|
|
639
671
|
|
|
@@ -682,6 +714,10 @@ export declare class UndirectedGraph<V = any, E = any, VO extends UndirectedVert
|
|
|
682
714
|
|
|
683
715
|
|
|
684
716
|
|
|
717
|
+
|
|
718
|
+
|
|
719
|
+
|
|
720
|
+
|
|
685
721
|
|
|
686
722
|
|
|
687
723
|
|
|
@@ -164,6 +164,10 @@ export declare class HashMap<K = any, V = any, R = [K, V]> extends IterableEntry
|
|
|
164
164
|
|
|
165
165
|
|
|
166
166
|
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
|
|
167
171
|
|
|
168
172
|
|
|
169
173
|
|
|
@@ -207,6 +211,10 @@ export declare class HashMap<K = any, V = any, R = [K, V]> extends IterableEntry
|
|
|
207
211
|
|
|
208
212
|
|
|
209
213
|
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
|
|
210
218
|
|
|
211
219
|
|
|
212
220
|
|
|
@@ -292,6 +300,14 @@ export declare class HashMap<K = any, V = any, R = [K, V]> extends IterableEntry
|
|
|
292
300
|
|
|
293
301
|
|
|
294
302
|
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
|
|
295
311
|
|
|
296
312
|
|
|
297
313
|
|
|
@@ -320,7 +336,7 @@ export declare class HashMap<K = any, V = any, R = [K, V]> extends IterableEntry
|
|
|
320
336
|
* // Verify entries
|
|
321
337
|
* console.log([...map.entries()]); // length: 4;
|
|
322
338
|
*/
|
|
323
|
-
set(key: K, value: V):
|
|
339
|
+
set(key: K, value: V): this;
|
|
324
340
|
/**
|
|
325
341
|
* Insert many entries from an iterable.
|
|
326
342
|
* @remarks Time O(N), Space O(N)
|
|
@@ -354,6 +370,10 @@ export declare class HashMap<K = any, V = any, R = [K, V]> extends IterableEntry
|
|
|
354
370
|
|
|
355
371
|
|
|
356
372
|
|
|
373
|
+
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
|
|
357
377
|
|
|
358
378
|
|
|
359
379
|
|
|
@@ -401,6 +421,10 @@ export declare class HashMap<K = any, V = any, R = [K, V]> extends IterableEntry
|
|
|
401
421
|
|
|
402
422
|
|
|
403
423
|
|
|
424
|
+
|
|
425
|
+
|
|
426
|
+
|
|
427
|
+
|
|
404
428
|
|
|
405
429
|
|
|
406
430
|
|
|
@@ -464,6 +488,10 @@ export declare class HashMap<K = any, V = any, R = [K, V]> extends IterableEntry
|
|
|
464
488
|
|
|
465
489
|
|
|
466
490
|
|
|
491
|
+
|
|
492
|
+
|
|
493
|
+
|
|
494
|
+
|
|
467
495
|
|
|
468
496
|
|
|
469
497
|
|
|
@@ -512,6 +540,10 @@ export declare class HashMap<K = any, V = any, R = [K, V]> extends IterableEntry
|
|
|
512
540
|
|
|
513
541
|
|
|
514
542
|
|
|
543
|
+
|
|
544
|
+
|
|
545
|
+
|
|
546
|
+
|
|
515
547
|
|
|
516
548
|
|
|
517
549
|
|
|
@@ -565,6 +597,10 @@ export declare class HashMap<K = any, V = any, R = [K, V]> extends IterableEntry
|
|
|
565
597
|
|
|
566
598
|
|
|
567
599
|
|
|
600
|
+
|
|
601
|
+
|
|
602
|
+
|
|
603
|
+
|
|
568
604
|
|
|
569
605
|
|
|
570
606
|
|
|
@@ -615,6 +651,10 @@ export declare class HashMap<K = any, V = any, R = [K, V]> extends IterableEntry
|
|
|
615
651
|
|
|
616
652
|
|
|
617
653
|
|
|
654
|
+
|
|
655
|
+
|
|
656
|
+
|
|
657
|
+
|
|
618
658
|
|
|
619
659
|
|
|
620
660
|
|
|
@@ -665,6 +705,10 @@ export declare class HashMap<K = any, V = any, R = [K, V]> extends IterableEntry
|
|
|
665
705
|
|
|
666
706
|
|
|
667
707
|
|
|
708
|
+
|
|
709
|
+
|
|
710
|
+
|
|
711
|
+
|
|
668
712
|
|
|
669
713
|
|
|
670
714
|
|
|
@@ -696,7 +740,7 @@ export declare class HashMap<K = any, V = any, R = [K, V]> extends IterableEntry
|
|
|
696
740
|
* console.log(values); // contains 3; // 'Bob', 'Eve'
|
|
697
741
|
* console.log(values); // contains 7;
|
|
698
742
|
*/
|
|
699
|
-
filter(predicate: EntryCallback<K, V, boolean>, thisArg?: unknown):
|
|
743
|
+
filter(predicate: EntryCallback<K, V, boolean>, thisArg?: unknown): this;
|
|
700
744
|
/**
|
|
701
745
|
* (Protected) Create a like-kind instance and seed it from an iterable.
|
|
702
746
|
* @remarks Time O(N), Space O(N)
|
|
@@ -796,9 +840,9 @@ export declare class LinkedHashMap<K = any, V = any, R = [K, V]> extends Iterabl
|
|
|
796
840
|
* @remarks Time O(1), Space O(1)
|
|
797
841
|
* @param key - Key.
|
|
798
842
|
* @param [value] - Value.
|
|
799
|
-
* @returns
|
|
843
|
+
* @returns This map (for chaining).
|
|
800
844
|
*/
|
|
801
|
-
set(key: K, value?: V):
|
|
845
|
+
set(key: K, value?: V): this;
|
|
802
846
|
setMany(entryOrRawElements: Iterable<R | [K, V]>): boolean[];
|
|
803
847
|
has(key: K): boolean;
|
|
804
848
|
get(key: K): V | undefined;
|
|
@@ -821,9 +865,10 @@ export declare class LinkedHashMap<K = any, V = any, R = [K, V]> extends Iterabl
|
|
|
821
865
|
* Delete the entry at a given index.
|
|
822
866
|
* @remarks Time O(N), Space O(1)
|
|
823
867
|
* @param index - Zero-based index.
|
|
824
|
-
* @returns
|
|
868
|
+
* @returns The removed entry [key, value].
|
|
869
|
+
* @throws {RangeError} If index is out of bounds.
|
|
825
870
|
*/
|
|
826
|
-
deleteAt(index: number):
|
|
871
|
+
deleteAt(index: number): [K, V | undefined];
|
|
827
872
|
isEmpty(): boolean;
|
|
828
873
|
isEntry(rawElement: unknown): rawElement is [K, V];
|
|
829
874
|
clear(): void;
|
|
@@ -9,7 +9,7 @@ import type { Comparator, DFSOrderPattern, ElementCallback, HeapOptions } from '
|
|
|
9
9
|
import { IterableElementBase } from '../base';
|
|
10
10
|
/**
|
|
11
11
|
* Binary heap with pluggable comparator; supports fast insertion and removal of the top element.
|
|
12
|
-
* @remarks
|
|
12
|
+
* @remarks Typical operations: O(log N) insert/remove, O(1) peek. Space O(N).
|
|
13
13
|
* @template E
|
|
14
14
|
* @template R
|
|
15
15
|
* 1. Complete Binary Tree: Heaps are typically complete binary trees, meaning every level is fully filled except possibly for the last level, which has nodes as far left as possible.
|
|
@@ -195,6 +195,10 @@ export declare class Heap<E = any, R = any> extends IterableElementBase<E, R> {
|
|
|
195
195
|
|
|
196
196
|
|
|
197
197
|
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
|
|
198
202
|
|
|
199
203
|
|
|
200
204
|
|
|
@@ -240,7 +244,7 @@ export declare class Heap<E = any, R = any> extends IterableElementBase<E, R> {
|
|
|
240
244
|
static heapify<EE = any, RR = any>(elements: Iterable<EE>, options: HeapOptions<EE, RR>): Heap<EE, RR>;
|
|
241
245
|
/**
|
|
242
246
|
* Insert an element.
|
|
243
|
-
* @remarks Time O(
|
|
247
|
+
* @remarks Time O(log N) amortized, Space O(1)
|
|
244
248
|
* @param element - Element to insert.
|
|
245
249
|
* @returns True.
|
|
246
250
|
|
|
@@ -273,6 +277,10 @@ export declare class Heap<E = any, R = any> extends IterableElementBase<E, R> {
|
|
|
273
277
|
|
|
274
278
|
|
|
275
279
|
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
|
|
276
284
|
|
|
277
285
|
|
|
278
286
|
|
|
@@ -327,6 +335,10 @@ export declare class Heap<E = any, R = any> extends IterableElementBase<E, R> {
|
|
|
327
335
|
|
|
328
336
|
|
|
329
337
|
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
|
|
330
342
|
|
|
331
343
|
|
|
332
344
|
|
|
@@ -375,10 +387,41 @@ export declare class Heap<E = any, R = any> extends IterableElementBase<E, R> {
|
|
|
375
387
|
|
|
376
388
|
|
|
377
389
|
|
|
390
|
+
|
|
391
|
+
|
|
392
|
+
|
|
378
393
|
|
|
379
394
|
|
|
380
395
|
|
|
381
396
|
|
|
397
|
+
* @example
|
|
398
|
+
* // Heap with custom comparator (MaxHeap behavior)
|
|
399
|
+
* interface Task {
|
|
400
|
+
* id: number;
|
|
401
|
+
* priority: number;
|
|
402
|
+
* name: string;
|
|
403
|
+
* }
|
|
404
|
+
*
|
|
405
|
+
* // Custom comparator for max heap behavior (higher priority first)
|
|
406
|
+
* const tasks: Task[] = [
|
|
407
|
+
* { id: 1, priority: 5, name: 'Email' },
|
|
408
|
+
* { id: 2, priority: 3, name: 'Chat' },
|
|
409
|
+
* { id: 3, priority: 8, name: 'Alert' }
|
|
410
|
+
* ];
|
|
411
|
+
*
|
|
412
|
+
* const maxHeap = new Heap(tasks, {
|
|
413
|
+
* comparator: (a: Task, b: Task) => b.priority - a.priority
|
|
414
|
+
* });
|
|
415
|
+
*
|
|
416
|
+
* console.log(maxHeap.size); // 3;
|
|
417
|
+
*
|
|
418
|
+
* // Peek returns highest priority task
|
|
419
|
+
* const topTask = maxHeap.peek();
|
|
420
|
+
* console.log(topTask?.priority); // 8;
|
|
421
|
+
* console.log(topTask?.name); // 'Alert';
|
|
422
|
+
*/
|
|
423
|
+
/**
|
|
424
|
+
* @deprecated Use `pop` instead. Will be removed in a future major version.
|
|
382
425
|
* @example
|
|
383
426
|
* // Heap with custom comparator (MaxHeap behavior)
|
|
384
427
|
* interface Task {
|
|
@@ -406,6 +449,12 @@ export declare class Heap<E = any, R = any> extends IterableElementBase<E, R> {
|
|
|
406
449
|
* console.log(topTask?.name); // 'Alert';
|
|
407
450
|
*/
|
|
408
451
|
poll(): E | undefined;
|
|
452
|
+
/**
|
|
453
|
+
* Remove and return the top element (min or max depending on comparator).
|
|
454
|
+
* @remarks Time O(log N) amortized, Space O(1)
|
|
455
|
+
* @returns The removed top element, or undefined if empty.
|
|
456
|
+
*/
|
|
457
|
+
pop(): E | undefined;
|
|
409
458
|
/**
|
|
410
459
|
* Get the current top element without removing it.
|
|
411
460
|
* @remarks Time O(1), Space O(1)
|
|
@@ -440,6 +489,10 @@ export declare class Heap<E = any, R = any> extends IterableElementBase<E, R> {
|
|
|
440
489
|
|
|
441
490
|
|
|
442
491
|
|
|
492
|
+
|
|
493
|
+
|
|
494
|
+
|
|
495
|
+
|
|
443
496
|
|
|
444
497
|
|
|
445
498
|
|
|
@@ -538,6 +591,10 @@ export declare class Heap<E = any, R = any> extends IterableElementBase<E, R> {
|
|
|
538
591
|
|
|
539
592
|
|
|
540
593
|
|
|
594
|
+
|
|
595
|
+
|
|
596
|
+
|
|
597
|
+
|
|
541
598
|
|
|
542
599
|
|
|
543
600
|
|
|
@@ -583,6 +640,10 @@ export declare class Heap<E = any, R = any> extends IterableElementBase<E, R> {
|
|
|
583
640
|
|
|
584
641
|
|
|
585
642
|
|
|
643
|
+
|
|
644
|
+
|
|
645
|
+
|
|
646
|
+
|
|
586
647
|
|
|
587
648
|
|
|
588
649
|
|
|
@@ -595,13 +656,6 @@ export declare class Heap<E = any, R = any> extends IterableElementBase<E, R> {
|
|
|
595
656
|
* console.log(heap.isEmpty()); // true;
|
|
596
657
|
*/
|
|
597
658
|
clear(): void;
|
|
598
|
-
/**
|
|
599
|
-
* Replace the backing array and rebuild the heap.
|
|
600
|
-
* @remarks Time O(N), Space O(N)
|
|
601
|
-
* @param elements - Iterable used to refill the heap.
|
|
602
|
-
* @returns Array of per-node results from fixing steps.
|
|
603
|
-
*/
|
|
604
|
-
refill(elements: Iterable<E>): boolean[];
|
|
605
659
|
/**
|
|
606
660
|
* Check if an equal element exists in the heap.
|
|
607
661
|
* @remarks Time O(N), Space O(1)
|
|
@@ -628,6 +682,10 @@ export declare class Heap<E = any, R = any> extends IterableElementBase<E, R> {
|
|
|
628
682
|
|
|
629
683
|
|
|
630
684
|
|
|
685
|
+
|
|
686
|
+
|
|
687
|
+
|
|
688
|
+
|
|
631
689
|
|
|
632
690
|
|
|
633
691
|
|
|
@@ -672,6 +730,10 @@ export declare class Heap<E = any, R = any> extends IterableElementBase<E, R> {
|
|
|
672
730
|
|
|
673
731
|
|
|
674
732
|
|
|
733
|
+
|
|
734
|
+
|
|
735
|
+
|
|
736
|
+
|
|
675
737
|
|
|
676
738
|
|
|
677
739
|
|
|
@@ -684,13 +746,17 @@ export declare class Heap<E = any, R = any> extends IterableElementBase<E, R> {
|
|
|
684
746
|
* console.log(heap.toArray().includes(4)); // false;
|
|
685
747
|
*/
|
|
686
748
|
delete(element: E): boolean;
|
|
749
|
+
/**
|
|
750
|
+
* @deprecated Use `deleteWhere` instead. Will be removed in a future major version.
|
|
751
|
+
*/
|
|
752
|
+
deleteBy(predicate: (element: E, index: number, heap: this) => boolean): boolean;
|
|
687
753
|
/**
|
|
688
754
|
* Delete the first element that matches a predicate.
|
|
689
755
|
* @remarks Time O(N), Space O(1)
|
|
690
756
|
* @param predicate - Function (element, index, heap) → boolean.
|
|
691
757
|
* @returns True if an element was removed.
|
|
692
758
|
*/
|
|
693
|
-
|
|
759
|
+
deleteWhere(predicate: (element: E, index: number, heap: this) => boolean): boolean;
|
|
694
760
|
/**
|
|
695
761
|
* Set the equality comparator used by has/delete operations.
|
|
696
762
|
* @remarks Time O(1), Space O(1)
|
|
@@ -724,6 +790,10 @@ export declare class Heap<E = any, R = any> extends IterableElementBase<E, R> {
|
|
|
724
790
|
|
|
725
791
|
|
|
726
792
|
|
|
793
|
+
|
|
794
|
+
|
|
795
|
+
|
|
796
|
+
|
|
727
797
|
|
|
728
798
|
|
|
729
799
|
|
|
@@ -776,6 +846,10 @@ export declare class Heap<E = any, R = any> extends IterableElementBase<E, R> {
|
|
|
776
846
|
|
|
777
847
|
|
|
778
848
|
|
|
849
|
+
|
|
850
|
+
|
|
851
|
+
|
|
852
|
+
|
|
779
853
|
|
|
780
854
|
|
|
781
855
|
|
|
@@ -820,6 +894,10 @@ export declare class Heap<E = any, R = any> extends IterableElementBase<E, R> {
|
|
|
820
894
|
|
|
821
895
|
|
|
822
896
|
|
|
897
|
+
|
|
898
|
+
|
|
899
|
+
|
|
900
|
+
|
|
823
901
|
|
|
824
902
|
|
|
825
903
|
|
|
@@ -868,6 +946,10 @@ export declare class Heap<E = any, R = any> extends IterableElementBase<E, R> {
|
|
|
868
946
|
|
|
869
947
|
|
|
870
948
|
|
|
949
|
+
|
|
950
|
+
|
|
951
|
+
|
|
952
|
+
|
|
871
953
|
|
|
872
954
|
|
|
873
955
|
|
|
@@ -916,6 +998,10 @@ export declare class Heap<E = any, R = any> extends IterableElementBase<E, R> {
|
|
|
916
998
|
|
|
917
999
|
|
|
918
1000
|
|
|
1001
|
+
|
|
1002
|
+
|
|
1003
|
+
|
|
1004
|
+
|
|
919
1005
|
|
|
920
1006
|
|
|
921
1007
|
|
|
@@ -1029,9 +1115,9 @@ export declare class FibonacciHeap<E> {
|
|
|
1029
1115
|
* Push an element into the root list.
|
|
1030
1116
|
* @remarks Time O(1) amortized, Space O(1)
|
|
1031
1117
|
* @param element - Element to insert.
|
|
1032
|
-
* @returns
|
|
1118
|
+
* @returns True when the element is added.
|
|
1033
1119
|
*/
|
|
1034
|
-
push(element: E):
|
|
1120
|
+
push(element: E): boolean;
|
|
1035
1121
|
peek(): E | undefined;
|
|
1036
1122
|
/**
|
|
1037
1123
|
* Collect nodes from a circular doubly linked list starting at head.
|