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
|
@@ -260,6 +260,27 @@ export class Deque<E = any, R = any> extends LinearBase<E, R> {
|
|
|
260
260
|
|
|
261
261
|
|
|
262
262
|
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
|
|
263
284
|
* @example
|
|
264
285
|
* // Deque peek at both ends
|
|
265
286
|
* const deque = new Deque<number>([10, 20, 30, 40, 50]);
|
|
@@ -296,6 +317,27 @@ export class Deque<E = any, R = any> extends LinearBase<E, R> {
|
|
|
296
317
|
|
|
297
318
|
|
|
298
319
|
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
|
|
299
341
|
* @example
|
|
300
342
|
* // Peek at the back element
|
|
301
343
|
* const dq = new Deque<string>(['a', 'b', 'c']);
|
|
@@ -346,6 +388,27 @@ export class Deque<E = any, R = any> extends LinearBase<E, R> {
|
|
|
346
388
|
|
|
347
389
|
|
|
348
390
|
|
|
391
|
+
|
|
392
|
+
|
|
393
|
+
|
|
394
|
+
|
|
395
|
+
|
|
396
|
+
|
|
397
|
+
|
|
398
|
+
|
|
399
|
+
|
|
400
|
+
|
|
401
|
+
|
|
402
|
+
|
|
403
|
+
|
|
404
|
+
|
|
405
|
+
|
|
406
|
+
|
|
407
|
+
|
|
408
|
+
|
|
409
|
+
|
|
410
|
+
|
|
411
|
+
|
|
349
412
|
* @example
|
|
350
413
|
* // basic Deque creation and push/pop operations
|
|
351
414
|
* // Create a simple Deque with initial values
|
|
@@ -400,6 +463,27 @@ export class Deque<E = any, R = any> extends LinearBase<E, R> {
|
|
|
400
463
|
|
|
401
464
|
|
|
402
465
|
|
|
466
|
+
|
|
467
|
+
|
|
468
|
+
|
|
469
|
+
|
|
470
|
+
|
|
471
|
+
|
|
472
|
+
|
|
473
|
+
|
|
474
|
+
|
|
475
|
+
|
|
476
|
+
|
|
477
|
+
|
|
478
|
+
|
|
479
|
+
|
|
480
|
+
|
|
481
|
+
|
|
482
|
+
|
|
483
|
+
|
|
484
|
+
|
|
485
|
+
|
|
486
|
+
|
|
403
487
|
* @example
|
|
404
488
|
* // Remove from the back
|
|
405
489
|
* const dq = new Deque<number>([1, 2, 3]);
|
|
@@ -441,6 +525,27 @@ export class Deque<E = any, R = any> extends LinearBase<E, R> {
|
|
|
441
525
|
|
|
442
526
|
|
|
443
527
|
|
|
528
|
+
|
|
529
|
+
|
|
530
|
+
|
|
531
|
+
|
|
532
|
+
|
|
533
|
+
|
|
534
|
+
|
|
535
|
+
|
|
536
|
+
|
|
537
|
+
|
|
538
|
+
|
|
539
|
+
|
|
540
|
+
|
|
541
|
+
|
|
542
|
+
|
|
543
|
+
|
|
544
|
+
|
|
545
|
+
|
|
546
|
+
|
|
547
|
+
|
|
548
|
+
|
|
444
549
|
* @example
|
|
445
550
|
* // Remove from the front
|
|
446
551
|
* const dq = new Deque<number>([1, 2, 3]);
|
|
@@ -483,6 +588,27 @@ export class Deque<E = any, R = any> extends LinearBase<E, R> {
|
|
|
483
588
|
|
|
484
589
|
|
|
485
590
|
|
|
591
|
+
|
|
592
|
+
|
|
593
|
+
|
|
594
|
+
|
|
595
|
+
|
|
596
|
+
|
|
597
|
+
|
|
598
|
+
|
|
599
|
+
|
|
600
|
+
|
|
601
|
+
|
|
602
|
+
|
|
603
|
+
|
|
604
|
+
|
|
605
|
+
|
|
606
|
+
|
|
607
|
+
|
|
608
|
+
|
|
609
|
+
|
|
610
|
+
|
|
611
|
+
|
|
486
612
|
* @example
|
|
487
613
|
* // Deque shift and unshift operations
|
|
488
614
|
* const deque = new Deque<number>([20, 30, 40]);
|
|
@@ -570,6 +696,27 @@ export class Deque<E = any, R = any> extends LinearBase<E, R> {
|
|
|
570
696
|
|
|
571
697
|
|
|
572
698
|
|
|
699
|
+
|
|
700
|
+
|
|
701
|
+
|
|
702
|
+
|
|
703
|
+
|
|
704
|
+
|
|
705
|
+
|
|
706
|
+
|
|
707
|
+
|
|
708
|
+
|
|
709
|
+
|
|
710
|
+
|
|
711
|
+
|
|
712
|
+
|
|
713
|
+
|
|
714
|
+
|
|
715
|
+
|
|
716
|
+
|
|
717
|
+
|
|
718
|
+
|
|
719
|
+
|
|
573
720
|
* @example
|
|
574
721
|
* // Check if empty
|
|
575
722
|
* const dq = new Deque();
|
|
@@ -593,6 +740,27 @@ export class Deque<E = any, R = any> extends LinearBase<E, R> {
|
|
|
593
740
|
|
|
594
741
|
|
|
595
742
|
|
|
743
|
+
|
|
744
|
+
|
|
745
|
+
|
|
746
|
+
|
|
747
|
+
|
|
748
|
+
|
|
749
|
+
|
|
750
|
+
|
|
751
|
+
|
|
752
|
+
|
|
753
|
+
|
|
754
|
+
|
|
755
|
+
|
|
756
|
+
|
|
757
|
+
|
|
758
|
+
|
|
759
|
+
|
|
760
|
+
|
|
761
|
+
|
|
762
|
+
|
|
763
|
+
|
|
596
764
|
* @example
|
|
597
765
|
* // Remove all elements
|
|
598
766
|
* const dq = new Deque<number>([1, 2, 3]);
|
|
@@ -620,6 +788,27 @@ export class Deque<E = any, R = any> extends LinearBase<E, R> {
|
|
|
620
788
|
|
|
621
789
|
|
|
622
790
|
|
|
791
|
+
|
|
792
|
+
|
|
793
|
+
|
|
794
|
+
|
|
795
|
+
|
|
796
|
+
|
|
797
|
+
|
|
798
|
+
|
|
799
|
+
|
|
800
|
+
|
|
801
|
+
|
|
802
|
+
|
|
803
|
+
|
|
804
|
+
|
|
805
|
+
|
|
806
|
+
|
|
807
|
+
|
|
808
|
+
|
|
809
|
+
|
|
810
|
+
|
|
811
|
+
|
|
623
812
|
* @example
|
|
624
813
|
* // Access by index
|
|
625
814
|
* const dq = new Deque<string>(['a', 'b', 'c']);
|
|
@@ -820,6 +1009,27 @@ export class Deque<E = any, R = any> extends LinearBase<E, R> {
|
|
|
820
1009
|
|
|
821
1010
|
|
|
822
1011
|
|
|
1012
|
+
|
|
1013
|
+
|
|
1014
|
+
|
|
1015
|
+
|
|
1016
|
+
|
|
1017
|
+
|
|
1018
|
+
|
|
1019
|
+
|
|
1020
|
+
|
|
1021
|
+
|
|
1022
|
+
|
|
1023
|
+
|
|
1024
|
+
|
|
1025
|
+
|
|
1026
|
+
|
|
1027
|
+
|
|
1028
|
+
|
|
1029
|
+
|
|
1030
|
+
|
|
1031
|
+
|
|
1032
|
+
|
|
823
1033
|
* @example
|
|
824
1034
|
* // Remove element
|
|
825
1035
|
* const dq = new Deque<number>([1, 2, 3]);
|
|
@@ -889,6 +1099,27 @@ export class Deque<E = any, R = any> extends LinearBase<E, R> {
|
|
|
889
1099
|
|
|
890
1100
|
|
|
891
1101
|
|
|
1102
|
+
|
|
1103
|
+
|
|
1104
|
+
|
|
1105
|
+
|
|
1106
|
+
|
|
1107
|
+
|
|
1108
|
+
|
|
1109
|
+
|
|
1110
|
+
|
|
1111
|
+
|
|
1112
|
+
|
|
1113
|
+
|
|
1114
|
+
|
|
1115
|
+
|
|
1116
|
+
|
|
1117
|
+
|
|
1118
|
+
|
|
1119
|
+
|
|
1120
|
+
|
|
1121
|
+
|
|
1122
|
+
|
|
892
1123
|
* @example
|
|
893
1124
|
* // Deque for...of iteration and reverse
|
|
894
1125
|
* const deque = new Deque<string>(['A', 'B', 'C', 'D']);
|
|
@@ -985,6 +1216,27 @@ export class Deque<E = any, R = any> extends LinearBase<E, R> {
|
|
|
985
1216
|
|
|
986
1217
|
|
|
987
1218
|
|
|
1219
|
+
|
|
1220
|
+
|
|
1221
|
+
|
|
1222
|
+
|
|
1223
|
+
|
|
1224
|
+
|
|
1225
|
+
|
|
1226
|
+
|
|
1227
|
+
|
|
1228
|
+
|
|
1229
|
+
|
|
1230
|
+
|
|
1231
|
+
|
|
1232
|
+
|
|
1233
|
+
|
|
1234
|
+
|
|
1235
|
+
|
|
1236
|
+
|
|
1237
|
+
|
|
1238
|
+
|
|
1239
|
+
|
|
988
1240
|
* @example
|
|
989
1241
|
* // Reclaim memory
|
|
990
1242
|
* const dq = new Deque<number>([1, 2, 3, 4, 5]);
|
|
@@ -1034,6 +1286,27 @@ export class Deque<E = any, R = any> extends LinearBase<E, R> {
|
|
|
1034
1286
|
|
|
1035
1287
|
|
|
1036
1288
|
|
|
1289
|
+
|
|
1290
|
+
|
|
1291
|
+
|
|
1292
|
+
|
|
1293
|
+
|
|
1294
|
+
|
|
1295
|
+
|
|
1296
|
+
|
|
1297
|
+
|
|
1298
|
+
|
|
1299
|
+
|
|
1300
|
+
|
|
1301
|
+
|
|
1302
|
+
|
|
1303
|
+
|
|
1304
|
+
|
|
1305
|
+
|
|
1306
|
+
|
|
1307
|
+
|
|
1308
|
+
|
|
1309
|
+
|
|
1037
1310
|
* @example
|
|
1038
1311
|
* // Create independent copy
|
|
1039
1312
|
* const dq = new Deque<number>([1, 2, 3]);
|
|
@@ -1066,6 +1339,27 @@ export class Deque<E = any, R = any> extends LinearBase<E, R> {
|
|
|
1066
1339
|
|
|
1067
1340
|
|
|
1068
1341
|
|
|
1342
|
+
|
|
1343
|
+
|
|
1344
|
+
|
|
1345
|
+
|
|
1346
|
+
|
|
1347
|
+
|
|
1348
|
+
|
|
1349
|
+
|
|
1350
|
+
|
|
1351
|
+
|
|
1352
|
+
|
|
1353
|
+
|
|
1354
|
+
|
|
1355
|
+
|
|
1356
|
+
|
|
1357
|
+
|
|
1358
|
+
|
|
1359
|
+
|
|
1360
|
+
|
|
1361
|
+
|
|
1362
|
+
|
|
1069
1363
|
* @example
|
|
1070
1364
|
* // Filter elements
|
|
1071
1365
|
* const dq = new Deque<number>([1, 2, 3, 4]);
|
|
@@ -1073,7 +1367,7 @@ export class Deque<E = any, R = any> extends LinearBase<E, R> {
|
|
|
1073
1367
|
* console.log(result.length); // 2;
|
|
1074
1368
|
*/
|
|
1075
1369
|
|
|
1076
|
-
filter(predicate: ElementCallback<E, R, boolean>, thisArg?:
|
|
1370
|
+
filter(predicate: ElementCallback<E, R, boolean>, thisArg?: unknown): this {
|
|
1077
1371
|
const out = this._createInstance({ toElementFn: this.toElementFn, maxLen: this._maxLen });
|
|
1078
1372
|
out._setBucketSize(this._bucketSize);
|
|
1079
1373
|
let index = 0;
|
|
@@ -1092,7 +1386,7 @@ export class Deque<E = any, R = any> extends LinearBase<E, R> {
|
|
|
1092
1386
|
* @returns A new deque with mapped values.
|
|
1093
1387
|
*/
|
|
1094
1388
|
|
|
1095
|
-
mapSame(callback: ElementCallback<E, R, E>, thisArg?:
|
|
1389
|
+
mapSame(callback: ElementCallback<E, R, E>, thisArg?: unknown): this {
|
|
1096
1390
|
const out = this._createInstance({ toElementFn: this._toElementFn, maxLen: this._maxLen });
|
|
1097
1391
|
out._setBucketSize(this._bucketSize);
|
|
1098
1392
|
let index = 0;
|
|
@@ -1120,6 +1414,27 @@ export class Deque<E = any, R = any> extends LinearBase<E, R> {
|
|
|
1120
1414
|
|
|
1121
1415
|
|
|
1122
1416
|
|
|
1417
|
+
|
|
1418
|
+
|
|
1419
|
+
|
|
1420
|
+
|
|
1421
|
+
|
|
1422
|
+
|
|
1423
|
+
|
|
1424
|
+
|
|
1425
|
+
|
|
1426
|
+
|
|
1427
|
+
|
|
1428
|
+
|
|
1429
|
+
|
|
1430
|
+
|
|
1431
|
+
|
|
1432
|
+
|
|
1433
|
+
|
|
1434
|
+
|
|
1435
|
+
|
|
1436
|
+
|
|
1437
|
+
|
|
1123
1438
|
* @example
|
|
1124
1439
|
* // Transform elements
|
|
1125
1440
|
* const dq = new Deque<number>([1, 2, 3]);
|
|
@@ -1130,7 +1445,7 @@ export class Deque<E = any, R = any> extends LinearBase<E, R> {
|
|
|
1130
1445
|
map<EM, RM>(
|
|
1131
1446
|
callback: ElementCallback<E, R, EM>,
|
|
1132
1447
|
options?: IterableElementBaseOptions<EM, RM>,
|
|
1133
|
-
thisArg?:
|
|
1448
|
+
thisArg?: unknown
|
|
1134
1449
|
): Deque<EM, RM> {
|
|
1135
1450
|
const out = this._createLike<EM, RM>([], {
|
|
1136
1451
|
...(options ?? {}),
|
|
@@ -1263,11 +1578,11 @@ export class Deque<E = any, R = any> extends LinearBase<E, R> {
|
|
|
1263
1578
|
protected _createLike<T = E, RR = R>(
|
|
1264
1579
|
elements: IterableWithSizeOrLength<T> | IterableWithSizeOrLength<RR> = [],
|
|
1265
1580
|
options?: DequeOptions<T, RR>
|
|
1266
|
-
):
|
|
1581
|
+
): Deque<T, RR> {
|
|
1267
1582
|
const Ctor = this.constructor as new (
|
|
1268
1583
|
elements?: IterableWithSizeOrLength<T> | IterableWithSizeOrLength<RR>,
|
|
1269
1584
|
options?: DequeOptions<T, RR>
|
|
1270
|
-
) =>
|
|
1585
|
+
) => Deque<T, RR>;
|
|
1271
1586
|
return new Ctor(elements, options);
|
|
1272
1587
|
}
|
|
1273
1588
|
|