max-priority-queue-typed 2.5.1 → 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 +207 -71
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs-legacy/index.cjs +206 -70
- package/dist/cjs-legacy/index.cjs.map +1 -1
- package/dist/esm/index.mjs +207 -72
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm-legacy/index.mjs +206 -71
- package/dist/esm-legacy/index.mjs.map +1 -1
- package/dist/types/common/error.d.ts +9 -0
- package/dist/types/common/index.d.ts +1 -1
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +86 -2
- package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +98 -0
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +189 -13
- package/dist/types/data-structures/binary-tree/bst.d.ts +270 -3
- package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +136 -8
- package/dist/types/data-structures/binary-tree/segment-tree.d.ts +42 -0
- package/dist/types/data-structures/binary-tree/tree-map.d.ts +1089 -161
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +1243 -350
- package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +980 -255
- package/dist/types/data-structures/binary-tree/tree-set.d.ts +1174 -284
- package/dist/types/data-structures/graph/directed-graph.d.ts +70 -0
- package/dist/types/data-structures/graph/undirected-graph.d.ts +63 -0
- package/dist/types/data-structures/hash/hash-map.d.ts +84 -6
- package/dist/types/data-structures/heap/heap.d.ts +140 -12
- package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +126 -0
- package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +106 -1
- package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +126 -0
- package/dist/types/data-structures/matrix/matrix.d.ts +56 -0
- package/dist/types/data-structures/queue/deque.d.ts +127 -0
- package/dist/types/data-structures/queue/queue.d.ts +97 -0
- package/dist/types/data-structures/stack/stack.d.ts +72 -2
- package/dist/types/data-structures/trie/trie.d.ts +84 -0
- package/dist/types/interfaces/binary-tree.d.ts +2 -3
- package/dist/types/types/data-structures/binary-tree/bst.d.ts +1 -0
- package/dist/types/types/data-structures/binary-tree/tree-map.d.ts +5 -0
- package/dist/types/types/data-structures/binary-tree/tree-multi-set.d.ts +4 -0
- package/dist/types/types/data-structures/binary-tree/tree-set.d.ts +4 -0
- package/dist/umd/max-priority-queue-typed.js +204 -69
- package/dist/umd/max-priority-queue-typed.js.map +1 -1
- package/dist/umd/max-priority-queue-typed.min.js +1 -1
- package/dist/umd/max-priority-queue-typed.min.js.map +1 -1
- package/package.json +2 -2
- package/src/common/error.ts +19 -1
- package/src/common/index.ts +1 -1
- package/src/data-structures/base/iterable-element-base.ts +3 -2
- package/src/data-structures/binary-tree/avl-tree.ts +99 -5
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +102 -4
- package/src/data-structures/binary-tree/binary-tree.ts +239 -78
- package/src/data-structures/binary-tree/bst.ts +542 -13
- package/src/data-structures/binary-tree/red-black-tree.ts +155 -15
- package/src/data-structures/binary-tree/segment-tree.ts +42 -0
- package/src/data-structures/binary-tree/tree-map.ts +1223 -261
- package/src/data-structures/binary-tree/tree-multi-map.ts +939 -30
- package/src/data-structures/binary-tree/tree-multi-set.ts +746 -10
- package/src/data-structures/binary-tree/tree-set.ts +1018 -99
- package/src/data-structures/graph/abstract-graph.ts +2 -2
- package/src/data-structures/graph/directed-graph.ts +71 -1
- package/src/data-structures/graph/undirected-graph.ts +64 -1
- package/src/data-structures/hash/hash-map.ts +102 -16
- package/src/data-structures/heap/heap.ts +153 -23
- package/src/data-structures/heap/max-heap.ts +2 -2
- package/src/data-structures/linked-list/doubly-linked-list.ts +139 -0
- package/src/data-structures/linked-list/singly-linked-list.ts +106 -1
- package/src/data-structures/linked-list/skip-linked-list.ts +131 -5
- package/src/data-structures/matrix/matrix.ts +65 -9
- package/src/data-structures/priority-queue/max-priority-queue.ts +2 -2
- package/src/data-structures/queue/deque.ts +130 -0
- package/src/data-structures/queue/queue.ts +109 -0
- package/src/data-structures/stack/stack.ts +75 -5
- package/src/data-structures/trie/trie.ts +86 -2
- package/src/interfaces/binary-tree.ts +1 -9
- package/src/types/data-structures/binary-tree/bst.ts +1 -0
- package/src/types/data-structures/binary-tree/tree-map.ts +6 -0
- package/src/types/data-structures/binary-tree/tree-multi-set.ts +5 -0
- package/src/types/data-structures/binary-tree/tree-set.ts +5 -0
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
import type { ElementCallback, TrieOptions } from '../../types';
|
|
10
10
|
import { IterableElementBase } from '../base';
|
|
11
|
-
import { ERR } from '../../common';
|
|
11
|
+
import { ERR, raise } from '../../common';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Node used by Trie to store one character and its children.
|
|
@@ -308,6 +308,13 @@ export class Trie<R = any> extends IterableElementBase<string, R> {
|
|
|
308
308
|
|
|
309
309
|
|
|
310
310
|
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
|
|
311
318
|
|
|
312
319
|
|
|
313
320
|
|
|
@@ -379,6 +386,13 @@ export class Trie<R = any> extends IterableElementBase<string, R> {
|
|
|
379
386
|
|
|
380
387
|
|
|
381
388
|
|
|
389
|
+
|
|
390
|
+
|
|
391
|
+
|
|
392
|
+
|
|
393
|
+
|
|
394
|
+
|
|
395
|
+
|
|
382
396
|
|
|
383
397
|
|
|
384
398
|
|
|
@@ -437,6 +451,13 @@ export class Trie<R = any> extends IterableElementBase<string, R> {
|
|
|
437
451
|
|
|
438
452
|
|
|
439
453
|
|
|
454
|
+
|
|
455
|
+
|
|
456
|
+
|
|
457
|
+
|
|
458
|
+
|
|
459
|
+
|
|
460
|
+
|
|
440
461
|
|
|
441
462
|
|
|
442
463
|
|
|
@@ -490,6 +511,13 @@ export class Trie<R = any> extends IterableElementBase<string, R> {
|
|
|
490
511
|
|
|
491
512
|
|
|
492
513
|
|
|
514
|
+
|
|
515
|
+
|
|
516
|
+
|
|
517
|
+
|
|
518
|
+
|
|
519
|
+
|
|
520
|
+
|
|
493
521
|
|
|
494
522
|
|
|
495
523
|
|
|
@@ -535,6 +563,13 @@ export class Trie<R = any> extends IterableElementBase<string, R> {
|
|
|
535
563
|
|
|
536
564
|
|
|
537
565
|
|
|
566
|
+
|
|
567
|
+
|
|
568
|
+
|
|
569
|
+
|
|
570
|
+
|
|
571
|
+
|
|
572
|
+
|
|
538
573
|
|
|
539
574
|
|
|
540
575
|
|
|
@@ -584,6 +619,13 @@ export class Trie<R = any> extends IterableElementBase<string, R> {
|
|
|
584
619
|
|
|
585
620
|
|
|
586
621
|
|
|
622
|
+
|
|
623
|
+
|
|
624
|
+
|
|
625
|
+
|
|
626
|
+
|
|
627
|
+
|
|
628
|
+
|
|
587
629
|
|
|
588
630
|
|
|
589
631
|
|
|
@@ -720,6 +762,13 @@ export class Trie<R = any> extends IterableElementBase<string, R> {
|
|
|
720
762
|
|
|
721
763
|
|
|
722
764
|
|
|
765
|
+
|
|
766
|
+
|
|
767
|
+
|
|
768
|
+
|
|
769
|
+
|
|
770
|
+
|
|
771
|
+
|
|
723
772
|
|
|
724
773
|
|
|
725
774
|
|
|
@@ -797,6 +846,13 @@ export class Trie<R = any> extends IterableElementBase<string, R> {
|
|
|
797
846
|
|
|
798
847
|
|
|
799
848
|
|
|
849
|
+
|
|
850
|
+
|
|
851
|
+
|
|
852
|
+
|
|
853
|
+
|
|
854
|
+
|
|
855
|
+
|
|
800
856
|
|
|
801
857
|
|
|
802
858
|
|
|
@@ -855,6 +911,13 @@ export class Trie<R = any> extends IterableElementBase<string, R> {
|
|
|
855
911
|
|
|
856
912
|
|
|
857
913
|
|
|
914
|
+
|
|
915
|
+
|
|
916
|
+
|
|
917
|
+
|
|
918
|
+
|
|
919
|
+
|
|
920
|
+
|
|
858
921
|
|
|
859
922
|
|
|
860
923
|
|
|
@@ -936,6 +999,13 @@ export class Trie<R = any> extends IterableElementBase<string, R> {
|
|
|
936
999
|
|
|
937
1000
|
|
|
938
1001
|
|
|
1002
|
+
|
|
1003
|
+
|
|
1004
|
+
|
|
1005
|
+
|
|
1006
|
+
|
|
1007
|
+
|
|
1008
|
+
|
|
939
1009
|
|
|
940
1010
|
|
|
941
1011
|
|
|
@@ -985,6 +1055,13 @@ export class Trie<R = any> extends IterableElementBase<string, R> {
|
|
|
985
1055
|
|
|
986
1056
|
|
|
987
1057
|
|
|
1058
|
+
|
|
1059
|
+
|
|
1060
|
+
|
|
1061
|
+
|
|
1062
|
+
|
|
1063
|
+
|
|
1064
|
+
|
|
988
1065
|
|
|
989
1066
|
|
|
990
1067
|
|
|
@@ -1035,6 +1112,13 @@ export class Trie<R = any> extends IterableElementBase<string, R> {
|
|
|
1035
1112
|
|
|
1036
1113
|
|
|
1037
1114
|
|
|
1115
|
+
|
|
1116
|
+
|
|
1117
|
+
|
|
1118
|
+
|
|
1119
|
+
|
|
1120
|
+
|
|
1121
|
+
|
|
1038
1122
|
|
|
1039
1123
|
|
|
1040
1124
|
|
|
@@ -1074,7 +1158,7 @@ export class Trie<R = any> extends IterableElementBase<string, R> {
|
|
|
1074
1158
|
for (const x of this) {
|
|
1075
1159
|
const v = thisArg === undefined ? callback(x, i++, this) : callback.call(thisArg, x, i++, this);
|
|
1076
1160
|
if (typeof v !== 'string') {
|
|
1077
|
-
|
|
1161
|
+
raise(TypeError, ERR.callbackReturnType('string', typeof v, 'Trie.map'));
|
|
1078
1162
|
}
|
|
1079
1163
|
newTrie.add(v);
|
|
1080
1164
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { BinaryTreeNode } from '../data-structures';
|
|
2
2
|
import type {
|
|
3
|
-
BinaryTreeDeleteResult,
|
|
4
3
|
BinaryTreeOptions,
|
|
5
4
|
BTNRep,
|
|
6
5
|
DFSOrderPattern,
|
|
@@ -51,7 +50,7 @@ export interface IBinaryTree<K = any, V = any, R = any> {
|
|
|
51
50
|
// Accept BTNRep, predicate, or raw R for deletion
|
|
52
51
|
delete(
|
|
53
52
|
keyNodeEntryRawOrPredicate: BTNRep<K, V, BinaryTreeNode<K, V>> | NodePredicate<BinaryTreeNode<K, V> | null>
|
|
54
|
-
):
|
|
53
|
+
): boolean;
|
|
55
54
|
|
|
56
55
|
clear(): void;
|
|
57
56
|
|
|
@@ -242,11 +241,4 @@ export interface IBinaryTree<K = any, V = any, R = any> {
|
|
|
242
241
|
|
|
243
242
|
// ---- bulk / interop ----
|
|
244
243
|
merge(anotherTree: IBinaryTree<K, V, R>): void;
|
|
245
|
-
|
|
246
|
-
refill(
|
|
247
|
-
keysNodesEntriesOrRaws: Iterable<
|
|
248
|
-
K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined | R
|
|
249
|
-
>,
|
|
250
|
-
values?: Iterable<V | undefined>
|
|
251
|
-
): void;
|
|
252
244
|
}
|
|
@@ -11,6 +11,12 @@ export interface TreeMapOptions<K, V, R = [K, V]> {
|
|
|
11
11
|
*/
|
|
12
12
|
isMapMode?: boolean;
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Enable order-statistic operations (select, rank, rangeByRank).
|
|
16
|
+
* When true, subtree counts are maintained on every node.
|
|
17
|
+
*/
|
|
18
|
+
enableOrderStatistic?: boolean;
|
|
19
|
+
|
|
14
20
|
/**
|
|
15
21
|
* Transform raw elements into `[key, value]` entries.
|
|
16
22
|
* When provided, the constructor accepts `Iterable<R>` instead of `Iterable<[K, V]>`.
|
|
@@ -11,6 +11,11 @@ export interface TreeMultiSetOptions<K, R = K> {
|
|
|
11
11
|
*/
|
|
12
12
|
isMapMode?: boolean;
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Enable order-statistic operations (select, rank, rangeByRank).
|
|
16
|
+
*/
|
|
17
|
+
enableOrderStatistic?: boolean;
|
|
18
|
+
|
|
14
19
|
/**
|
|
15
20
|
* Transform raw elements into keys.
|
|
16
21
|
* When provided, the constructor accepts `Iterable<R>` instead of `Iterable<K>`.
|
|
@@ -11,6 +11,11 @@ export interface TreeSetOptions<K, R = K> {
|
|
|
11
11
|
*/
|
|
12
12
|
isMapMode?: boolean;
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Enable order-statistic operations (select, rank, rangeByRank).
|
|
16
|
+
*/
|
|
17
|
+
enableOrderStatistic?: boolean;
|
|
18
|
+
|
|
14
19
|
/**
|
|
15
20
|
* Transform raw elements into keys.
|
|
16
21
|
* When provided, the constructor accepts `Iterable<R>` instead of `Iterable<K>`.
|