max-priority-queue-typed 2.5.0 → 2.5.1
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 +294 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs-legacy/index.cjs +294 -0
- package/dist/cjs-legacy/index.cjs.map +1 -1
- package/dist/esm/index.mjs +294 -0
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm-legacy/index.mjs +294 -0
- package/dist/esm-legacy/index.mjs.map +1 -1
- package/dist/types/data-structures/base/index.d.ts +1 -0
- package/dist/types/data-structures/base/iterable-entry-base.d.ts +8 -8
- package/dist/types/data-structures/base/linear-base.d.ts +3 -3
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +252 -0
- package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +294 -0
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +527 -2
- package/dist/types/data-structures/binary-tree/bst.d.ts +505 -1
- package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +399 -0
- package/dist/types/data-structures/binary-tree/segment-tree.d.ts +126 -1
- package/dist/types/data-structures/binary-tree/tree-map.d.ts +2881 -382
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +2867 -347
- package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +2328 -312
- package/dist/types/data-structures/binary-tree/tree-set.d.ts +2671 -277
- package/dist/types/data-structures/graph/abstract-graph.d.ts +4 -4
- package/dist/types/data-structures/graph/directed-graph.d.ts +210 -0
- package/dist/types/data-structures/graph/undirected-graph.d.ts +189 -0
- package/dist/types/data-structures/hash/hash-map.d.ts +241 -10
- package/dist/types/data-structures/heap/heap.d.ts +294 -0
- package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +360 -3
- package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +318 -3
- package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +380 -2
- package/dist/types/data-structures/matrix/matrix.d.ts +168 -0
- package/dist/types/data-structures/queue/deque.d.ts +319 -4
- package/dist/types/data-structures/queue/queue.d.ts +252 -0
- package/dist/types/data-structures/stack/stack.d.ts +210 -0
- package/dist/types/data-structures/trie/trie.d.ts +256 -4
- package/dist/types/interfaces/graph.d.ts +1 -1
- package/dist/types/types/common.d.ts +2 -2
- package/dist/types/types/data-structures/heap/heap.d.ts +1 -0
- package/dist/types/types/data-structures/priority-queue/priority-queue.d.ts +1 -0
- package/dist/types/types/utils/validate-type.d.ts +4 -4
- package/dist/umd/max-priority-queue-typed.js +294 -0
- package/dist/umd/max-priority-queue-typed.js.map +1 -1
- package/dist/umd/max-priority-queue-typed.min.js.map +1 -1
- package/package.json +2 -2
- package/src/data-structures/base/index.ts +1 -0
- package/src/data-structures/base/iterable-entry-base.ts +8 -8
- package/src/data-structures/base/linear-base.ts +3 -3
- package/src/data-structures/binary-tree/avl-tree.ts +252 -0
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +295 -1
- package/src/data-structures/binary-tree/binary-tree.ts +527 -2
- package/src/data-structures/binary-tree/bst.ts +505 -1
- package/src/data-structures/binary-tree/red-black-tree.ts +399 -0
- package/src/data-structures/binary-tree/segment-tree.ts +127 -2
- package/src/data-structures/binary-tree/tree-map.ts +2958 -459
- package/src/data-structures/binary-tree/tree-multi-map.ts +3069 -549
- package/src/data-structures/binary-tree/tree-multi-set.ts +2476 -460
- package/src/data-structures/binary-tree/tree-set.ts +2816 -422
- package/src/data-structures/graph/abstract-graph.ts +4 -4
- package/src/data-structures/graph/directed-graph.ts +210 -0
- package/src/data-structures/graph/undirected-graph.ts +189 -0
- package/src/data-structures/hash/hash-map.ts +246 -15
- package/src/data-structures/heap/heap.ts +294 -0
- package/src/data-structures/linked-list/doubly-linked-list.ts +360 -3
- package/src/data-structures/linked-list/singly-linked-list.ts +318 -3
- package/src/data-structures/linked-list/skip-linked-list.ts +380 -2
- package/src/data-structures/matrix/matrix.ts +169 -1
- package/src/data-structures/queue/deque.ts +320 -5
- package/src/data-structures/queue/queue.ts +252 -0
- package/src/data-structures/stack/stack.ts +210 -0
- package/src/data-structures/trie/trie.ts +257 -5
- package/src/interfaces/graph.ts +1 -1
- package/src/types/common.ts +2 -2
- package/src/types/data-structures/heap/heap.ts +1 -0
- package/src/types/data-structures/priority-queue/priority-queue.ts +1 -0
- package/src/types/utils/validate-type.ts +4 -4
|
@@ -177,6 +177,27 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
|
|
|
177
177
|
|
|
178
178
|
|
|
179
179
|
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
|
|
180
201
|
* @example
|
|
181
202
|
* // Deque peek at both ends
|
|
182
203
|
* const deque = new Deque<number>([10, 20, 30, 40, 50]);
|
|
@@ -208,6 +229,27 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
|
|
|
208
229
|
|
|
209
230
|
|
|
210
231
|
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
|
|
211
253
|
* @example
|
|
212
254
|
* // Peek at the back element
|
|
213
255
|
* const dq = new Deque<string>(['a', 'b', 'c']);
|
|
@@ -242,6 +284,27 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
|
|
|
242
284
|
|
|
243
285
|
|
|
244
286
|
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
|
|
245
308
|
* @example
|
|
246
309
|
* // basic Deque creation and push/pop operations
|
|
247
310
|
* // Create a simple Deque with initial values
|
|
@@ -277,6 +340,27 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
|
|
|
277
340
|
|
|
278
341
|
|
|
279
342
|
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
|
|
280
364
|
* @example
|
|
281
365
|
* // Remove from the back
|
|
282
366
|
* const dq = new Deque<number>([1, 2, 3]);
|
|
@@ -299,6 +383,27 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
|
|
|
299
383
|
|
|
300
384
|
|
|
301
385
|
|
|
386
|
+
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
|
|
390
|
+
|
|
391
|
+
|
|
392
|
+
|
|
393
|
+
|
|
394
|
+
|
|
395
|
+
|
|
396
|
+
|
|
397
|
+
|
|
398
|
+
|
|
399
|
+
|
|
400
|
+
|
|
401
|
+
|
|
402
|
+
|
|
403
|
+
|
|
404
|
+
|
|
405
|
+
|
|
406
|
+
|
|
302
407
|
* @example
|
|
303
408
|
* // Remove from the front
|
|
304
409
|
* const dq = new Deque<number>([1, 2, 3]);
|
|
@@ -322,6 +427,27 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
|
|
|
322
427
|
|
|
323
428
|
|
|
324
429
|
|
|
430
|
+
|
|
431
|
+
|
|
432
|
+
|
|
433
|
+
|
|
434
|
+
|
|
435
|
+
|
|
436
|
+
|
|
437
|
+
|
|
438
|
+
|
|
439
|
+
|
|
440
|
+
|
|
441
|
+
|
|
442
|
+
|
|
443
|
+
|
|
444
|
+
|
|
445
|
+
|
|
446
|
+
|
|
447
|
+
|
|
448
|
+
|
|
449
|
+
|
|
450
|
+
|
|
325
451
|
* @example
|
|
326
452
|
* // Deque shift and unshift operations
|
|
327
453
|
* const deque = new Deque<number>([20, 30, 40]);
|
|
@@ -366,6 +492,27 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
|
|
|
366
492
|
|
|
367
493
|
|
|
368
494
|
|
|
495
|
+
|
|
496
|
+
|
|
497
|
+
|
|
498
|
+
|
|
499
|
+
|
|
500
|
+
|
|
501
|
+
|
|
502
|
+
|
|
503
|
+
|
|
504
|
+
|
|
505
|
+
|
|
506
|
+
|
|
507
|
+
|
|
508
|
+
|
|
509
|
+
|
|
510
|
+
|
|
511
|
+
|
|
512
|
+
|
|
513
|
+
|
|
514
|
+
|
|
515
|
+
|
|
369
516
|
* @example
|
|
370
517
|
* // Check if empty
|
|
371
518
|
* const dq = new Deque();
|
|
@@ -385,6 +532,27 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
|
|
|
385
532
|
|
|
386
533
|
|
|
387
534
|
|
|
535
|
+
|
|
536
|
+
|
|
537
|
+
|
|
538
|
+
|
|
539
|
+
|
|
540
|
+
|
|
541
|
+
|
|
542
|
+
|
|
543
|
+
|
|
544
|
+
|
|
545
|
+
|
|
546
|
+
|
|
547
|
+
|
|
548
|
+
|
|
549
|
+
|
|
550
|
+
|
|
551
|
+
|
|
552
|
+
|
|
553
|
+
|
|
554
|
+
|
|
555
|
+
|
|
388
556
|
* @example
|
|
389
557
|
* // Remove all elements
|
|
390
558
|
* const dq = new Deque<number>([1, 2, 3]);
|
|
@@ -405,6 +573,27 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
|
|
|
405
573
|
|
|
406
574
|
|
|
407
575
|
|
|
576
|
+
|
|
577
|
+
|
|
578
|
+
|
|
579
|
+
|
|
580
|
+
|
|
581
|
+
|
|
582
|
+
|
|
583
|
+
|
|
584
|
+
|
|
585
|
+
|
|
586
|
+
|
|
587
|
+
|
|
588
|
+
|
|
589
|
+
|
|
590
|
+
|
|
591
|
+
|
|
592
|
+
|
|
593
|
+
|
|
594
|
+
|
|
595
|
+
|
|
596
|
+
|
|
408
597
|
* @example
|
|
409
598
|
* // Access by index
|
|
410
599
|
* const dq = new Deque<string>(['a', 'b', 'c']);
|
|
@@ -474,6 +663,27 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
|
|
|
474
663
|
|
|
475
664
|
|
|
476
665
|
|
|
666
|
+
|
|
667
|
+
|
|
668
|
+
|
|
669
|
+
|
|
670
|
+
|
|
671
|
+
|
|
672
|
+
|
|
673
|
+
|
|
674
|
+
|
|
675
|
+
|
|
676
|
+
|
|
677
|
+
|
|
678
|
+
|
|
679
|
+
|
|
680
|
+
|
|
681
|
+
|
|
682
|
+
|
|
683
|
+
|
|
684
|
+
|
|
685
|
+
|
|
686
|
+
|
|
477
687
|
* @example
|
|
478
688
|
* // Remove element
|
|
479
689
|
* const dq = new Deque<number>([1, 2, 3]);
|
|
@@ -510,6 +720,27 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
|
|
|
510
720
|
|
|
511
721
|
|
|
512
722
|
|
|
723
|
+
|
|
724
|
+
|
|
725
|
+
|
|
726
|
+
|
|
727
|
+
|
|
728
|
+
|
|
729
|
+
|
|
730
|
+
|
|
731
|
+
|
|
732
|
+
|
|
733
|
+
|
|
734
|
+
|
|
735
|
+
|
|
736
|
+
|
|
737
|
+
|
|
738
|
+
|
|
739
|
+
|
|
740
|
+
|
|
741
|
+
|
|
742
|
+
|
|
743
|
+
|
|
513
744
|
* @example
|
|
514
745
|
* // Deque for...of iteration and reverse
|
|
515
746
|
* const deque = new Deque<string>(['A', 'B', 'C', 'D']);
|
|
@@ -564,6 +795,27 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
|
|
|
564
795
|
|
|
565
796
|
|
|
566
797
|
|
|
798
|
+
|
|
799
|
+
|
|
800
|
+
|
|
801
|
+
|
|
802
|
+
|
|
803
|
+
|
|
804
|
+
|
|
805
|
+
|
|
806
|
+
|
|
807
|
+
|
|
808
|
+
|
|
809
|
+
|
|
810
|
+
|
|
811
|
+
|
|
812
|
+
|
|
813
|
+
|
|
814
|
+
|
|
815
|
+
|
|
816
|
+
|
|
817
|
+
|
|
818
|
+
|
|
567
819
|
* @example
|
|
568
820
|
* // Reclaim memory
|
|
569
821
|
* const dq = new Deque<number>([1, 2, 3, 4, 5]);
|
|
@@ -587,6 +839,27 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
|
|
|
587
839
|
|
|
588
840
|
|
|
589
841
|
|
|
842
|
+
|
|
843
|
+
|
|
844
|
+
|
|
845
|
+
|
|
846
|
+
|
|
847
|
+
|
|
848
|
+
|
|
849
|
+
|
|
850
|
+
|
|
851
|
+
|
|
852
|
+
|
|
853
|
+
|
|
854
|
+
|
|
855
|
+
|
|
856
|
+
|
|
857
|
+
|
|
858
|
+
|
|
859
|
+
|
|
860
|
+
|
|
861
|
+
|
|
862
|
+
|
|
590
863
|
* @example
|
|
591
864
|
* // Create independent copy
|
|
592
865
|
* const dq = new Deque<number>([1, 2, 3]);
|
|
@@ -611,13 +884,34 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
|
|
|
611
884
|
|
|
612
885
|
|
|
613
886
|
|
|
887
|
+
|
|
888
|
+
|
|
889
|
+
|
|
890
|
+
|
|
891
|
+
|
|
892
|
+
|
|
893
|
+
|
|
894
|
+
|
|
895
|
+
|
|
896
|
+
|
|
897
|
+
|
|
898
|
+
|
|
899
|
+
|
|
900
|
+
|
|
901
|
+
|
|
902
|
+
|
|
903
|
+
|
|
904
|
+
|
|
905
|
+
|
|
906
|
+
|
|
907
|
+
|
|
614
908
|
* @example
|
|
615
909
|
* // Filter elements
|
|
616
910
|
* const dq = new Deque<number>([1, 2, 3, 4]);
|
|
617
911
|
* const result = dq.filter(x => x > 2);
|
|
618
912
|
* console.log(result.length); // 2;
|
|
619
913
|
*/
|
|
620
|
-
filter(predicate: ElementCallback<E, R, boolean>, thisArg?:
|
|
914
|
+
filter(predicate: ElementCallback<E, R, boolean>, thisArg?: unknown): this;
|
|
621
915
|
/**
|
|
622
916
|
* Map elements into a new deque of the same element type.
|
|
623
917
|
* @remarks Time O(N), Space O(N)
|
|
@@ -625,7 +919,7 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
|
|
|
625
919
|
* @param [thisArg] - Value for `this` inside the callback.
|
|
626
920
|
* @returns A new deque with mapped values.
|
|
627
921
|
*/
|
|
628
|
-
mapSame(callback: ElementCallback<E, R, E>, thisArg?:
|
|
922
|
+
mapSame(callback: ElementCallback<E, R, E>, thisArg?: unknown): this;
|
|
629
923
|
/**
|
|
630
924
|
* Map elements into a new deque (possibly different element type).
|
|
631
925
|
* @remarks Time O(N), Space O(N)
|
|
@@ -643,13 +937,34 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
|
|
|
643
937
|
|
|
644
938
|
|
|
645
939
|
|
|
940
|
+
|
|
941
|
+
|
|
942
|
+
|
|
943
|
+
|
|
944
|
+
|
|
945
|
+
|
|
946
|
+
|
|
947
|
+
|
|
948
|
+
|
|
949
|
+
|
|
950
|
+
|
|
951
|
+
|
|
952
|
+
|
|
953
|
+
|
|
954
|
+
|
|
955
|
+
|
|
956
|
+
|
|
957
|
+
|
|
958
|
+
|
|
959
|
+
|
|
960
|
+
|
|
646
961
|
* @example
|
|
647
962
|
* // Transform elements
|
|
648
963
|
* const dq = new Deque<number>([1, 2, 3]);
|
|
649
964
|
* const result = dq.map(x => x * 10);
|
|
650
965
|
* console.log(result.toArray()); // [10, 20, 30];
|
|
651
966
|
*/
|
|
652
|
-
map<EM, RM>(callback: ElementCallback<E, R, EM>, options?: IterableElementBaseOptions<EM, RM>, thisArg?:
|
|
967
|
+
map<EM, RM>(callback: ElementCallback<E, R, EM>, options?: IterableElementBaseOptions<EM, RM>, thisArg?: unknown): Deque<EM, RM>;
|
|
653
968
|
/**
|
|
654
969
|
* (Protected) Set the internal bucket size.
|
|
655
970
|
* @remarks Time O(1), Space O(1)
|
|
@@ -696,7 +1011,7 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
|
|
|
696
1011
|
* @param [options] - Options forwarded to the constructor.
|
|
697
1012
|
* @returns A like-kind Deque instance.
|
|
698
1013
|
*/
|
|
699
|
-
protected _createLike<T = E, RR = R>(elements?: IterableWithSizeOrLength<T> | IterableWithSizeOrLength<RR>, options?: DequeOptions<T, RR>):
|
|
1014
|
+
protected _createLike<T = E, RR = R>(elements?: IterableWithSizeOrLength<T> | IterableWithSizeOrLength<RR>, options?: DequeOptions<T, RR>): Deque<T, RR>;
|
|
700
1015
|
/**
|
|
701
1016
|
* (Protected) Iterate elements from back to front.
|
|
702
1017
|
* @remarks Time O(N), Space O(1)
|