max-priority-queue-typed 2.5.2 → 2.6.0

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.
Files changed (63) hide show
  1. package/dist/cjs/index.cjs +174 -16
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/cjs-legacy/index.cjs +174 -16
  4. package/dist/cjs-legacy/index.cjs.map +1 -1
  5. package/dist/esm/index.mjs +174 -16
  6. package/dist/esm/index.mjs.map +1 -1
  7. package/dist/esm-legacy/index.mjs +174 -16
  8. package/dist/esm-legacy/index.mjs.map +1 -1
  9. package/dist/types/data-structures/base/iterable-element-base.d.ts +17 -0
  10. package/dist/types/data-structures/base/linear-base.d.ts +6 -0
  11. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +86 -2
  12. package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +98 -0
  13. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +191 -15
  14. package/dist/types/data-structures/binary-tree/bst.d.ts +171 -3
  15. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +136 -8
  16. package/dist/types/data-structures/binary-tree/segment-tree.d.ts +42 -0
  17. package/dist/types/data-structures/binary-tree/tree-map.d.ts +1061 -167
  18. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +1232 -355
  19. package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +916 -194
  20. package/dist/types/data-structures/binary-tree/tree-set.d.ts +1078 -141
  21. package/dist/types/data-structures/graph/directed-graph.d.ts +70 -0
  22. package/dist/types/data-structures/graph/undirected-graph.d.ts +63 -0
  23. package/dist/types/data-structures/hash/hash-map.d.ts +84 -6
  24. package/dist/types/data-structures/heap/heap.d.ts +140 -12
  25. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +150 -2
  26. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +106 -1
  27. package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +126 -0
  28. package/dist/types/data-structures/matrix/matrix.d.ts +56 -0
  29. package/dist/types/data-structures/queue/deque.d.ts +171 -0
  30. package/dist/types/data-structures/queue/queue.d.ts +97 -0
  31. package/dist/types/data-structures/stack/stack.d.ts +72 -2
  32. package/dist/types/data-structures/trie/trie.d.ts +84 -0
  33. package/dist/types/interfaces/binary-tree.d.ts +2 -3
  34. package/dist/umd/max-priority-queue-typed.js +174 -16
  35. package/dist/umd/max-priority-queue-typed.js.map +1 -1
  36. package/dist/umd/max-priority-queue-typed.min.js +1 -1
  37. package/dist/umd/max-priority-queue-typed.min.js.map +1 -1
  38. package/package.json +2 -2
  39. package/src/data-structures/base/iterable-element-base.ts +32 -0
  40. package/src/data-structures/base/linear-base.ts +11 -0
  41. package/src/data-structures/binary-tree/avl-tree.ts +88 -5
  42. package/src/data-structures/binary-tree/binary-indexed-tree.ts +98 -0
  43. package/src/data-structures/binary-tree/binary-tree.ts +242 -81
  44. package/src/data-structures/binary-tree/bst.ts +173 -7
  45. package/src/data-structures/binary-tree/red-black-tree.ts +139 -15
  46. package/src/data-structures/binary-tree/segment-tree.ts +42 -0
  47. package/src/data-structures/binary-tree/tree-map.ts +948 -36
  48. package/src/data-structures/binary-tree/tree-multi-map.ts +893 -13
  49. package/src/data-structures/binary-tree/tree-multi-set.ts +761 -33
  50. package/src/data-structures/binary-tree/tree-set.ts +1260 -251
  51. package/src/data-structures/graph/directed-graph.ts +71 -1
  52. package/src/data-structures/graph/undirected-graph.ts +64 -1
  53. package/src/data-structures/hash/hash-map.ts +100 -12
  54. package/src/data-structures/heap/heap.ts +149 -19
  55. package/src/data-structures/linked-list/doubly-linked-list.ts +178 -2
  56. package/src/data-structures/linked-list/singly-linked-list.ts +106 -1
  57. package/src/data-structures/linked-list/skip-linked-list.ts +126 -0
  58. package/src/data-structures/matrix/matrix.ts +56 -0
  59. package/src/data-structures/queue/deque.ts +187 -0
  60. package/src/data-structures/queue/queue.ts +109 -0
  61. package/src/data-structures/stack/stack.ts +75 -5
  62. package/src/data-structures/trie/trie.ts +84 -0
  63. package/src/interfaces/binary-tree.ts +1 -9
@@ -5,7 +5,7 @@
5
5
  * @copyright Copyright (c) 2022 Pablo Zeng <zrwusa@gmail.com>
6
6
  * @license MIT License
7
7
  */
8
- import type { BinaryTreeDeleteResult, BSTNOptKeyOrNode, BSTOptions, BTNRep, Comparator, DFSOrderPattern, EntryCallback, FamilyPosition, IterationType, NodeCallback, NodePredicate, OptNode, RBTNColor } from '../../types';
8
+ import type { BSTNOptKeyOrNode, BSTOptions, BTNRep, Comparator, DFSOrderPattern, EntryCallback, FamilyPosition, IterationType, NodeCallback, NodePredicate, OptNode, RBTNColor } from '../../types';
9
9
  import { BinaryTree } from './binary-tree';
10
10
  import { IBinaryTree } from '../../interfaces';
11
11
  import { Range } from '../../common';
@@ -366,6 +366,20 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
366
366
 
367
367
 
368
368
 
369
+
370
+
371
+
372
+
373
+
374
+
375
+
376
+
377
+
378
+
379
+
380
+
381
+
382
+
369
383
 
370
384
 
371
385
 
@@ -438,6 +452,20 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
438
452
 
439
453
 
440
454
 
455
+
456
+
457
+
458
+
459
+
460
+
461
+
462
+
463
+
464
+
465
+
466
+
467
+
468
+
441
469
 
442
470
 
443
471
 
@@ -513,6 +541,20 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
513
541
 
514
542
 
515
543
 
544
+
545
+
546
+
547
+
548
+
549
+
550
+
551
+
552
+
553
+
554
+
555
+
556
+
557
+
516
558
 
517
559
 
518
560
 
@@ -532,7 +574,7 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
532
574
  * // Level-order grouping
533
575
  * const bst = new BST<number>([5, 3, 7, 1, 4]);
534
576
  * const levels = bst.listLevels(node => node.key);
535
- * console.log(levels.length); // > 0;
577
+ * console.log(levels); // toBeInstanceOf;
536
578
  * console.log(levels[0].length); // 1; // root level has 1 node
537
579
  * const allKeys = levels.flat().sort((a, b) => a - b);
538
580
  * console.log(allKeys); // [1, 3, 4, 5, 7];
@@ -599,6 +641,20 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
599
641
 
600
642
 
601
643
 
644
+
645
+
646
+
647
+
648
+
649
+
650
+
651
+
652
+
653
+
654
+
655
+
656
+
657
+
602
658
 
603
659
 
604
660
 
@@ -669,6 +725,20 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
669
725
 
670
726
 
671
727
 
728
+
729
+
730
+
731
+
732
+
733
+
734
+
735
+
736
+
737
+
738
+
739
+
740
+
741
+
672
742
 
673
743
 
674
744
 
@@ -721,6 +791,13 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
721
791
 
722
792
 
723
793
 
794
+
795
+
796
+
797
+
798
+
799
+
800
+
724
801
 
725
802
 
726
803
 
@@ -882,6 +959,27 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
882
959
 
883
960
 
884
961
 
962
+
963
+
964
+
965
+
966
+
967
+
968
+
969
+
970
+
971
+
972
+
973
+
974
+
975
+
976
+
977
+
978
+
979
+
980
+
981
+
982
+
885
983
 
886
984
 
887
985
 
@@ -966,6 +1064,20 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
966
1064
 
967
1065
 
968
1066
 
1067
+
1068
+
1069
+
1070
+
1071
+
1072
+
1073
+
1074
+
1075
+
1076
+
1077
+
1078
+
1079
+
1080
+
969
1081
 
970
1082
 
971
1083
 
@@ -1021,6 +1133,13 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
1021
1133
 
1022
1134
 
1023
1135
 
1136
+
1137
+
1138
+
1139
+
1140
+
1141
+
1142
+
1024
1143
 
1025
1144
 
1026
1145
 
@@ -1075,6 +1194,13 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
1075
1194
 
1076
1195
 
1077
1196
 
1197
+
1198
+
1199
+
1200
+
1201
+
1202
+
1203
+
1078
1204
 
1079
1205
 
1080
1206
 
@@ -1128,6 +1254,13 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
1128
1254
 
1129
1255
 
1130
1256
 
1257
+
1258
+
1259
+
1260
+
1261
+
1262
+
1263
+
1131
1264
 
1132
1265
 
1133
1266
 
@@ -1182,6 +1315,13 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
1182
1315
 
1183
1316
 
1184
1317
 
1318
+
1319
+
1320
+
1321
+
1322
+
1323
+
1324
+
1185
1325
 
1186
1326
 
1187
1327
 
@@ -1236,6 +1376,13 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
1236
1376
 
1237
1377
 
1238
1378
 
1379
+
1380
+
1381
+
1382
+
1383
+
1384
+
1385
+
1239
1386
 
1240
1387
 
1241
1388
 
@@ -1285,6 +1432,13 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
1285
1432
 
1286
1433
 
1287
1434
 
1435
+
1436
+
1437
+
1438
+
1439
+
1440
+
1441
+
1288
1442
 
1289
1443
 
1290
1444
 
@@ -1363,6 +1517,20 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
1363
1517
 
1364
1518
 
1365
1519
 
1520
+
1521
+
1522
+
1523
+
1524
+
1525
+
1526
+
1527
+
1528
+
1529
+
1530
+
1531
+
1532
+
1533
+
1366
1534
 
1367
1535
 
1368
1536
 
@@ -1421,7 +1589,7 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
1421
1589
  * - Value: true if the deletion succeeded, false if it failed (e.g., key not found during deletion phase).
1422
1590
  * - If no nodes match the search criteria, the returned map is empty.
1423
1591
  */
1424
- deleteWhere(keyNodeEntryOrPredicate: K | BSTNode<K, V> | [K | null | undefined, V | undefined] | null | undefined | NodePredicate<BSTNode<K, V>> | Range<K>, onlyOne?: boolean, startNode?: K | BSTNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, iterationType?: IterationType): BinaryTreeDeleteResult<BSTNode<K, V>>[];
1592
+ deleteWhere(keyNodeEntryOrPredicate: K | BSTNode<K, V> | [K | null | undefined, V | undefined] | null | undefined | NodePredicate<BSTNode<K, V>> | Range<K>, onlyOne?: boolean, startNode?: K | BSTNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, iterationType?: IterationType): boolean;
1425
1593
  /**
1426
1594
  * (Protected) Creates the default comparator function for keys that don't have a custom comparator.
1427
1595
  * @remarks Time O(1) Space O(1)
@@ -5,7 +5,7 @@
5
5
  * @copyright Copyright (c) 2022 Pablo Zeng <zrwusa@gmail.com>
6
6
  * @license MIT License
7
7
  */
8
- import type { BinaryTreeDeleteResult, BTNRep, CRUD, EntryCallback, FamilyPosition, NodePredicate, RBTNColor, IterationType, RedBlackTreeOptions } from '../../types';
8
+ import type { BTNRep, CRUD, EntryCallback, FamilyPosition, NodePredicate, RBTNColor, IterationType, RedBlackTreeOptions } from '../../types';
9
9
  import { BST } from './bst';
10
10
  import { IBinaryTree } from '../../interfaces';
11
11
  export declare class RedBlackTreeNode<K = any, V = any> {
@@ -217,13 +217,36 @@ export declare class RedBlackTree<K = any, V = any, R = any> extends BST<K, V, R
217
217
  */
218
218
  isNode(keyNodeOrEntry: K | RedBlackTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined): keyNodeOrEntry is RedBlackTreeNode<K, V>;
219
219
  /**
220
- * Remove all nodes and clear the key→value store (if in map mode).
220
+ * Remove all nodes, clear the key→value store (if in map mode) and internal caches.
221
221
  * @remarks Time O(n), Space O(1)
222
- * @returns void
223
- */
224
- /**
225
- * Remove all nodes and clear internal caches.
226
- * @remarks Time O(n) average, Space O(1)
222
+
223
+
224
+
225
+
226
+
227
+
228
+
229
+
230
+
231
+
232
+
233
+
234
+
235
+
236
+
237
+
238
+
239
+
240
+
241
+
242
+
243
+
244
+
245
+
246
+
247
+
248
+
249
+
227
250
 
228
251
 
229
252
 
@@ -572,6 +595,34 @@ export declare class RedBlackTree<K = any, V = any, R = any> extends BST<K, V, R
572
595
 
573
596
 
574
597
 
598
+
599
+
600
+
601
+
602
+
603
+
604
+
605
+
606
+
607
+
608
+
609
+
610
+
611
+
612
+
613
+
614
+
615
+
616
+
617
+
618
+
619
+
620
+
621
+
622
+
623
+
624
+
625
+
575
626
 
576
627
 
577
628
 
@@ -730,6 +781,34 @@ export declare class RedBlackTree<K = any, V = any, R = any> extends BST<K, V, R
730
781
 
731
782
 
732
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
+
733
812
 
734
813
 
735
814
 
@@ -758,7 +837,7 @@ export declare class RedBlackTree<K = any, V = any, R = any> extends BST<K, V, R
758
837
  * console.log(rbt.has(5)); // false;
759
838
  * console.log(rbt.size); // 4;
760
839
  */
761
- delete(keyNodeEntryRawOrPredicate: BTNRep<K, V, RedBlackTreeNode<K, V>> | NodePredicate<RedBlackTreeNode<K, V> | null>): BinaryTreeDeleteResult<RedBlackTreeNode<K, V>>[];
840
+ delete(keyNodeEntryRawOrPredicate: BTNRep<K, V, RedBlackTreeNode<K, V>> | NodePredicate<RedBlackTreeNode<K, V> | null>): boolean;
762
841
  /**
763
842
  * Transform entries into a like-kind red-black tree with possibly different key/value types.
764
843
  * @remarks Time O(n) average, Space O(n)
@@ -850,6 +929,27 @@ export declare class RedBlackTree<K = any, V = any, R = any> extends BST<K, V, R
850
929
 
851
930
 
852
931
 
932
+
933
+
934
+
935
+
936
+
937
+
938
+
939
+
940
+
941
+
942
+
943
+
944
+
945
+
946
+
947
+
948
+
949
+
950
+
951
+
952
+
853
953
 
854
954
 
855
955
 
@@ -990,6 +1090,34 @@ export declare class RedBlackTree<K = any, V = any, R = any> extends BST<K, V, R
990
1090
 
991
1091
 
992
1092
 
1093
+
1094
+
1095
+
1096
+
1097
+
1098
+
1099
+
1100
+
1101
+
1102
+
1103
+
1104
+
1105
+
1106
+
1107
+
1108
+
1109
+
1110
+
1111
+
1112
+
1113
+
1114
+
1115
+
1116
+
1117
+
1118
+
1119
+
1120
+
993
1121
 
994
1122
 
995
1123
 
@@ -72,6 +72,13 @@ export declare class SegmentTree<E = number> implements Iterable<E> {
72
72
 
73
73
 
74
74
 
75
+
76
+
77
+
78
+
79
+
80
+
81
+
75
82
 
76
83
 
77
84
 
@@ -133,6 +140,13 @@ export declare class SegmentTree<E = number> implements Iterable<E> {
133
140
 
134
141
 
135
142
 
143
+
144
+
145
+
146
+
147
+
148
+
149
+
136
150
 
137
151
 
138
152
 
@@ -190,6 +204,13 @@ export declare class SegmentTree<E = number> implements Iterable<E> {
190
204
 
191
205
 
192
206
 
207
+
208
+
209
+
210
+
211
+
212
+
213
+
193
214
 
194
215
 
195
216
 
@@ -242,6 +263,13 @@ export declare class SegmentTree<E = number> implements Iterable<E> {
242
263
 
243
264
 
244
265
 
266
+
267
+
268
+
269
+
270
+
271
+
272
+
245
273
 
246
274
 
247
275
 
@@ -289,6 +317,13 @@ export declare class SegmentTree<E = number> implements Iterable<E> {
289
317
 
290
318
 
291
319
 
320
+
321
+
322
+
323
+
324
+
325
+
326
+
292
327
 
293
328
 
294
329
 
@@ -339,6 +374,13 @@ export declare class SegmentTree<E = number> implements Iterable<E> {
339
374
 
340
375
 
341
376
 
377
+
378
+
379
+
380
+
381
+
382
+
383
+
342
384
 
343
385
 
344
386