tree-multimap-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.
- package/dist/types/data-structures/base/iterable-element-base.d.ts +17 -0
- package/dist/types/data-structures/base/linear-base.d.ts +6 -0
- 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 +191 -15
- package/dist/types/data-structures/binary-tree/bst.d.ts +171 -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 +1061 -167
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +1232 -355
- package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +916 -194
- package/dist/types/data-structures/binary-tree/tree-set.d.ts +1078 -141
- 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 +150 -2
- 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 +171 -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/umd/tree-multimap-typed.js +7783 -2483
- package/dist/umd/tree-multimap-typed.js.map +1 -1
- package/dist/umd/tree-multimap-typed.min.js +4 -4
- package/dist/umd/tree-multimap-typed.min.js.map +1 -1
- package/package.json +2 -2
- package/src/data-structures/base/iterable-element-base.ts +32 -0
- package/src/data-structures/base/linear-base.ts +11 -0
- package/src/data-structures/binary-tree/avl-tree.ts +88 -5
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +98 -0
- package/src/data-structures/binary-tree/binary-tree.ts +242 -81
- package/src/data-structures/binary-tree/bst.ts +173 -7
- package/src/data-structures/binary-tree/red-black-tree.ts +139 -15
- package/src/data-structures/binary-tree/segment-tree.ts +42 -0
- package/src/data-structures/binary-tree/tree-map.ts +948 -36
- package/src/data-structures/binary-tree/tree-multi-map.ts +893 -13
- package/src/data-structures/binary-tree/tree-multi-set.ts +761 -33
- package/src/data-structures/binary-tree/tree-set.ts +1260 -251
- 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 +100 -12
- package/src/data-structures/heap/heap.ts +149 -19
- package/src/data-structures/linked-list/doubly-linked-list.ts +178 -2
- package/src/data-structures/linked-list/singly-linked-list.ts +106 -1
- package/src/data-structures/linked-list/skip-linked-list.ts +126 -0
- package/src/data-structures/matrix/matrix.ts +56 -0
- package/src/data-structures/queue/deque.ts +187 -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 +84 -0
- package/src/interfaces/binary-tree.ts +1 -9
|
@@ -118,6 +118,23 @@ export declare abstract class IterableElementBase<E, R> implements Iterable<E> {
|
|
|
118
118
|
* Time O(n) in the worst case. Space O(1).
|
|
119
119
|
*/
|
|
120
120
|
has(element: E): boolean;
|
|
121
|
+
/**
|
|
122
|
+
* Check whether a value exists (Array-compatible alias for `has`).
|
|
123
|
+
* @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1).
|
|
124
|
+
* @param element - Element to search for (uses `===`).
|
|
125
|
+
* @returns `true` if found.
|
|
126
|
+
*/
|
|
127
|
+
includes(element: E): boolean;
|
|
128
|
+
/**
|
|
129
|
+
* Return an iterator of `[index, value]` pairs (Array-compatible).
|
|
130
|
+
* @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
|
|
131
|
+
*/
|
|
132
|
+
entries(): IterableIterator<[number, E]>;
|
|
133
|
+
/**
|
|
134
|
+
* Return an iterator of numeric indices (Array-compatible).
|
|
135
|
+
* @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
|
|
136
|
+
*/
|
|
137
|
+
keys(): IterableIterator<number>;
|
|
121
138
|
reduce(callbackfn: ReduceElementCallback<E, R>): E;
|
|
122
139
|
reduce(callbackfn: ReduceElementCallback<E, R>, initialValue: E): E;
|
|
123
140
|
reduce<U>(callbackfn: ReduceElementCallback<E, R, U>, initialValue: U): U;
|
|
@@ -173,6 +173,12 @@ export declare abstract class LinearBase<E, R = any, NODE extends LinkedListNode
|
|
|
173
173
|
* @remarks Time O(n), Space O(1)
|
|
174
174
|
*/
|
|
175
175
|
abstract reverse(): this;
|
|
176
|
+
/**
|
|
177
|
+
* Return a new instance of the same type with elements in reverse order (non-mutating).
|
|
178
|
+
* @remarks Provided for familiarity when migrating from Array (ES2023 `toReversed`). Time O(n), Space O(n).
|
|
179
|
+
* @returns A new reversed instance.
|
|
180
|
+
*/
|
|
181
|
+
toReversed(): this;
|
|
176
182
|
/**
|
|
177
183
|
* Append one element or node to the tail.
|
|
178
184
|
* @param elementOrNode - Element or node.
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @license MIT License
|
|
7
7
|
*/
|
|
8
8
|
import { BST } from './bst';
|
|
9
|
-
import type { AVLTreeOptions,
|
|
9
|
+
import type { AVLTreeOptions, BinaryTreeOptions, BSTNOptKeyOrNode, EntryCallback, FamilyPosition, IterationType, RBTNColor } from '../../types';
|
|
10
10
|
import { IBinaryTree } from '../../interfaces';
|
|
11
11
|
/**
|
|
12
12
|
* Represents a Node in an AVL (Adelson-Velsky and Landis) Tree.
|
|
@@ -378,6 +378,34 @@ export declare class AVLTree<K = any, V = any, R = any> extends BST<K, V, R> imp
|
|
|
378
378
|
|
|
379
379
|
|
|
380
380
|
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
|
|
384
|
+
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
|
|
390
|
+
|
|
391
|
+
|
|
392
|
+
|
|
393
|
+
|
|
394
|
+
|
|
395
|
+
|
|
396
|
+
|
|
397
|
+
|
|
398
|
+
|
|
399
|
+
|
|
400
|
+
|
|
401
|
+
|
|
402
|
+
|
|
403
|
+
|
|
404
|
+
|
|
405
|
+
|
|
406
|
+
|
|
407
|
+
|
|
408
|
+
|
|
381
409
|
|
|
382
410
|
|
|
383
411
|
|
|
@@ -497,6 +525,27 @@ export declare class AVLTree<K = any, V = any, R = any> extends BST<K, V, R> imp
|
|
|
497
525
|
|
|
498
526
|
|
|
499
527
|
|
|
528
|
+
|
|
529
|
+
|
|
530
|
+
|
|
531
|
+
|
|
532
|
+
|
|
533
|
+
|
|
534
|
+
|
|
535
|
+
|
|
536
|
+
|
|
537
|
+
|
|
538
|
+
|
|
539
|
+
|
|
540
|
+
|
|
541
|
+
|
|
542
|
+
|
|
543
|
+
|
|
544
|
+
|
|
545
|
+
|
|
546
|
+
|
|
547
|
+
|
|
548
|
+
|
|
500
549
|
|
|
501
550
|
|
|
502
551
|
|
|
@@ -525,7 +574,7 @@ export declare class AVLTree<K = any, V = any, R = any> extends BST<K, V, R> imp
|
|
|
525
574
|
* console.log(avl.has(3)); // false;
|
|
526
575
|
* console.log(avl.size); // 6;
|
|
527
576
|
*/
|
|
528
|
-
delete(keyNodeOrEntry: K | AVLTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined):
|
|
577
|
+
delete(keyNodeOrEntry: K | AVLTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined): boolean;
|
|
529
578
|
/**
|
|
530
579
|
* Rebuilds the tree to be perfectly balanced.
|
|
531
580
|
* @remarks AVL trees are already height-balanced, but this makes them *perfectly* balanced (minimal height and all leaves at N or N-1).
|
|
@@ -578,6 +627,20 @@ export declare class AVLTree<K = any, V = any, R = any> extends BST<K, V, R> imp
|
|
|
578
627
|
|
|
579
628
|
|
|
580
629
|
|
|
630
|
+
|
|
631
|
+
|
|
632
|
+
|
|
633
|
+
|
|
634
|
+
|
|
635
|
+
|
|
636
|
+
|
|
637
|
+
|
|
638
|
+
|
|
639
|
+
|
|
640
|
+
|
|
641
|
+
|
|
642
|
+
|
|
643
|
+
|
|
581
644
|
|
|
582
645
|
|
|
583
646
|
|
|
@@ -687,6 +750,27 @@ export declare class AVLTree<K = any, V = any, R = any> extends BST<K, V, R> imp
|
|
|
687
750
|
|
|
688
751
|
|
|
689
752
|
|
|
753
|
+
|
|
754
|
+
|
|
755
|
+
|
|
756
|
+
|
|
757
|
+
|
|
758
|
+
|
|
759
|
+
|
|
760
|
+
|
|
761
|
+
|
|
762
|
+
|
|
763
|
+
|
|
764
|
+
|
|
765
|
+
|
|
766
|
+
|
|
767
|
+
|
|
768
|
+
|
|
769
|
+
|
|
770
|
+
|
|
771
|
+
|
|
772
|
+
|
|
773
|
+
|
|
690
774
|
|
|
691
775
|
|
|
692
776
|
|
|
@@ -76,6 +76,20 @@ export declare class BinaryIndexedTree implements Iterable<number> {
|
|
|
76
76
|
|
|
77
77
|
|
|
78
78
|
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
|
|
79
93
|
|
|
80
94
|
|
|
81
95
|
|
|
@@ -149,6 +163,20 @@ export declare class BinaryIndexedTree implements Iterable<number> {
|
|
|
149
163
|
|
|
150
164
|
|
|
151
165
|
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
|
|
152
180
|
|
|
153
181
|
|
|
154
182
|
|
|
@@ -221,6 +249,20 @@ export declare class BinaryIndexedTree implements Iterable<number> {
|
|
|
221
249
|
|
|
222
250
|
|
|
223
251
|
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
|
|
224
266
|
|
|
225
267
|
|
|
226
268
|
|
|
@@ -294,6 +336,20 @@ export declare class BinaryIndexedTree implements Iterable<number> {
|
|
|
294
336
|
|
|
295
337
|
|
|
296
338
|
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
|
|
297
353
|
|
|
298
354
|
|
|
299
355
|
|
|
@@ -365,6 +421,20 @@ export declare class BinaryIndexedTree implements Iterable<number> {
|
|
|
365
421
|
|
|
366
422
|
|
|
367
423
|
|
|
424
|
+
|
|
425
|
+
|
|
426
|
+
|
|
427
|
+
|
|
428
|
+
|
|
429
|
+
|
|
430
|
+
|
|
431
|
+
|
|
432
|
+
|
|
433
|
+
|
|
434
|
+
|
|
435
|
+
|
|
436
|
+
|
|
437
|
+
|
|
368
438
|
|
|
369
439
|
|
|
370
440
|
|
|
@@ -439,6 +509,20 @@ export declare class BinaryIndexedTree implements Iterable<number> {
|
|
|
439
509
|
|
|
440
510
|
|
|
441
511
|
|
|
512
|
+
|
|
513
|
+
|
|
514
|
+
|
|
515
|
+
|
|
516
|
+
|
|
517
|
+
|
|
518
|
+
|
|
519
|
+
|
|
520
|
+
|
|
521
|
+
|
|
522
|
+
|
|
523
|
+
|
|
524
|
+
|
|
525
|
+
|
|
442
526
|
|
|
443
527
|
|
|
444
528
|
|
|
@@ -484,6 +568,13 @@ export declare class BinaryIndexedTree implements Iterable<number> {
|
|
|
484
568
|
|
|
485
569
|
|
|
486
570
|
|
|
571
|
+
|
|
572
|
+
|
|
573
|
+
|
|
574
|
+
|
|
575
|
+
|
|
576
|
+
|
|
577
|
+
|
|
487
578
|
|
|
488
579
|
|
|
489
580
|
|
|
@@ -524,6 +615,13 @@ export declare class BinaryIndexedTree implements Iterable<number> {
|
|
|
524
615
|
|
|
525
616
|
|
|
526
617
|
|
|
618
|
+
|
|
619
|
+
|
|
620
|
+
|
|
621
|
+
|
|
622
|
+
|
|
623
|
+
|
|
624
|
+
|
|
527
625
|
|
|
528
626
|
|
|
529
627
|
|