binary-tree-typed 2.5.2 → 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 +194 -55
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs-legacy/index.cjs +194 -55
- package/dist/cjs-legacy/index.cjs.map +1 -1
- package/dist/esm/index.mjs +194 -55
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm-legacy/index.mjs +194 -55
- package/dist/esm-legacy/index.mjs.map +1 -1
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +50 -2
- package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +56 -0
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +116 -15
- package/dist/types/data-structures/binary-tree/bst.d.ts +99 -3
- package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +79 -8
- package/dist/types/data-structures/binary-tree/segment-tree.d.ts +24 -0
- package/dist/types/data-structures/binary-tree/tree-map.d.ts +520 -1
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +489 -1
- package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +393 -1
- package/dist/types/data-structures/binary-tree/tree-set.d.ts +500 -1
- package/dist/types/data-structures/graph/directed-graph.d.ts +40 -0
- package/dist/types/data-structures/graph/undirected-graph.d.ts +36 -0
- package/dist/types/data-structures/hash/hash-map.d.ts +51 -6
- package/dist/types/data-structures/heap/heap.d.ts +98 -12
- package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +75 -0
- package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +61 -1
- package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +72 -0
- package/dist/types/data-structures/matrix/matrix.d.ts +32 -0
- package/dist/types/data-structures/queue/deque.d.ts +82 -0
- package/dist/types/data-structures/queue/queue.d.ts +61 -0
- package/dist/types/data-structures/stack/stack.d.ts +42 -2
- package/dist/types/data-structures/trie/trie.d.ts +48 -0
- package/dist/types/interfaces/binary-tree.d.ts +2 -3
- package/dist/umd/binary-tree-typed.js +194 -55
- package/dist/umd/binary-tree-typed.js.map +1 -1
- package/dist/umd/binary-tree-typed.min.js +5 -5
- package/dist/umd/binary-tree-typed.min.js.map +1 -1
- package/package.json +2 -2
- package/src/data-structures/binary-tree/avl-tree.ts +52 -5
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +56 -0
- package/src/data-structures/binary-tree/binary-tree.ts +167 -81
- package/src/data-structures/binary-tree/bst.ts +101 -7
- package/src/data-structures/binary-tree/red-black-tree.ts +82 -15
- package/src/data-structures/binary-tree/segment-tree.ts +24 -0
- package/src/data-structures/binary-tree/tree-map.ts +540 -3
- package/src/data-structures/binary-tree/tree-multi-map.ts +490 -2
- package/src/data-structures/binary-tree/tree-multi-set.ts +393 -1
- package/src/data-structures/binary-tree/tree-set.ts +520 -3
- package/src/data-structures/graph/directed-graph.ts +41 -1
- package/src/data-structures/graph/undirected-graph.ts +37 -1
- package/src/data-structures/hash/hash-map.ts +67 -12
- package/src/data-structures/heap/heap.ts +107 -19
- package/src/data-structures/linked-list/doubly-linked-list.ts +88 -0
- package/src/data-structures/linked-list/singly-linked-list.ts +61 -1
- package/src/data-structures/linked-list/skip-linked-list.ts +72 -0
- package/src/data-structures/matrix/matrix.ts +32 -0
- package/src/data-structures/queue/deque.ts +85 -0
- package/src/data-structures/queue/queue.ts +73 -0
- package/src/data-structures/stack/stack.ts +45 -5
- package/src/data-structures/trie/trie.ts +48 -0
- package/src/interfaces/binary-tree.ts +1 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "binary-tree-typed",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.3",
|
|
4
4
|
"description": "Binary Tree. Javascript & Typescript Data Structure.",
|
|
5
5
|
"browser": "dist/umd/binary-tree-typed.min.js",
|
|
6
6
|
"umd:main": "dist/umd/binary-tree-typed.min.js",
|
|
@@ -178,6 +178,6 @@
|
|
|
178
178
|
"typescript": "^4.9.5"
|
|
179
179
|
},
|
|
180
180
|
"dependencies": {
|
|
181
|
-
"data-structure-typed": "^2.5.
|
|
181
|
+
"data-structure-typed": "^2.5.3"
|
|
182
182
|
}
|
|
183
183
|
}
|
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
import { BST } from './bst';
|
|
10
10
|
import type {
|
|
11
11
|
AVLTreeOptions,
|
|
12
|
-
BinaryTreeDeleteResult,
|
|
13
12
|
BinaryTreeOptions,
|
|
14
13
|
BSTNOptKeyOrNode,
|
|
15
14
|
EntryCallback,
|
|
@@ -475,6 +474,22 @@ export class AVLTree<K = any, V = any, R = any> extends BST<K, V, R> implements
|
|
|
475
474
|
|
|
476
475
|
|
|
477
476
|
|
|
477
|
+
|
|
478
|
+
|
|
479
|
+
|
|
480
|
+
|
|
481
|
+
|
|
482
|
+
|
|
483
|
+
|
|
484
|
+
|
|
485
|
+
|
|
486
|
+
|
|
487
|
+
|
|
488
|
+
|
|
489
|
+
|
|
490
|
+
|
|
491
|
+
|
|
492
|
+
|
|
478
493
|
|
|
479
494
|
|
|
480
495
|
|
|
@@ -608,6 +623,18 @@ export class AVLTree<K = any, V = any, R = any> extends BST<K, V, R> implements
|
|
|
608
623
|
|
|
609
624
|
|
|
610
625
|
|
|
626
|
+
|
|
627
|
+
|
|
628
|
+
|
|
629
|
+
|
|
630
|
+
|
|
631
|
+
|
|
632
|
+
|
|
633
|
+
|
|
634
|
+
|
|
635
|
+
|
|
636
|
+
|
|
637
|
+
|
|
611
638
|
|
|
612
639
|
|
|
613
640
|
|
|
@@ -630,15 +657,15 @@ export class AVLTree<K = any, V = any, R = any> extends BST<K, V, R> implements
|
|
|
630
657
|
*/
|
|
631
658
|
override delete(
|
|
632
659
|
keyNodeOrEntry: K | AVLTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined
|
|
633
|
-
):
|
|
634
|
-
const deletedResults =
|
|
660
|
+
): boolean {
|
|
661
|
+
const deletedResults = this._deleteInternal(keyNodeOrEntry);
|
|
635
662
|
// After deletion, balance the path from the parent of the *physically deleted* node.
|
|
636
663
|
for (const { needBalanced } of deletedResults) {
|
|
637
664
|
if (needBalanced) {
|
|
638
|
-
this._balancePath(needBalanced);
|
|
665
|
+
this._balancePath(needBalanced as AVLTreeNode<K, V>);
|
|
639
666
|
}
|
|
640
667
|
}
|
|
641
|
-
return deletedResults;
|
|
668
|
+
return deletedResults.length > 0;
|
|
642
669
|
}
|
|
643
670
|
|
|
644
671
|
/**
|
|
@@ -699,6 +726,14 @@ export class AVLTree<K = any, V = any, R = any> extends BST<K, V, R> implements
|
|
|
699
726
|
|
|
700
727
|
|
|
701
728
|
|
|
729
|
+
|
|
730
|
+
|
|
731
|
+
|
|
732
|
+
|
|
733
|
+
|
|
734
|
+
|
|
735
|
+
|
|
736
|
+
|
|
702
737
|
|
|
703
738
|
|
|
704
739
|
|
|
@@ -838,6 +873,18 @@ export class AVLTree<K = any, V = any, R = any> extends BST<K, V, R> implements
|
|
|
838
873
|
|
|
839
874
|
|
|
840
875
|
|
|
876
|
+
|
|
877
|
+
|
|
878
|
+
|
|
879
|
+
|
|
880
|
+
|
|
881
|
+
|
|
882
|
+
|
|
883
|
+
|
|
884
|
+
|
|
885
|
+
|
|
886
|
+
|
|
887
|
+
|
|
841
888
|
|
|
842
889
|
|
|
843
890
|
|
|
@@ -109,6 +109,14 @@ export class BinaryIndexedTree implements Iterable<number> {
|
|
|
109
109
|
|
|
110
110
|
|
|
111
111
|
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
|
|
112
120
|
|
|
113
121
|
|
|
114
122
|
|
|
@@ -186,6 +194,14 @@ export class BinaryIndexedTree implements Iterable<number> {
|
|
|
186
194
|
|
|
187
195
|
|
|
188
196
|
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
|
|
189
205
|
|
|
190
206
|
|
|
191
207
|
|
|
@@ -263,6 +279,14 @@ export class BinaryIndexedTree implements Iterable<number> {
|
|
|
263
279
|
|
|
264
280
|
|
|
265
281
|
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
|
|
266
290
|
|
|
267
291
|
|
|
268
292
|
|
|
@@ -340,6 +364,14 @@ export class BinaryIndexedTree implements Iterable<number> {
|
|
|
340
364
|
|
|
341
365
|
|
|
342
366
|
|
|
367
|
+
|
|
368
|
+
|
|
369
|
+
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
|
|
343
375
|
|
|
344
376
|
|
|
345
377
|
|
|
@@ -415,6 +447,14 @@ export class BinaryIndexedTree implements Iterable<number> {
|
|
|
415
447
|
|
|
416
448
|
|
|
417
449
|
|
|
450
|
+
|
|
451
|
+
|
|
452
|
+
|
|
453
|
+
|
|
454
|
+
|
|
455
|
+
|
|
456
|
+
|
|
457
|
+
|
|
418
458
|
|
|
419
459
|
|
|
420
460
|
|
|
@@ -498,6 +538,14 @@ export class BinaryIndexedTree implements Iterable<number> {
|
|
|
498
538
|
|
|
499
539
|
|
|
500
540
|
|
|
541
|
+
|
|
542
|
+
|
|
543
|
+
|
|
544
|
+
|
|
545
|
+
|
|
546
|
+
|
|
547
|
+
|
|
548
|
+
|
|
501
549
|
|
|
502
550
|
|
|
503
551
|
|
|
@@ -555,6 +603,10 @@ export class BinaryIndexedTree implements Iterable<number> {
|
|
|
555
603
|
|
|
556
604
|
|
|
557
605
|
|
|
606
|
+
|
|
607
|
+
|
|
608
|
+
|
|
609
|
+
|
|
558
610
|
|
|
559
611
|
|
|
560
612
|
|
|
@@ -624,6 +676,10 @@ export class BinaryIndexedTree implements Iterable<number> {
|
|
|
624
676
|
|
|
625
677
|
|
|
626
678
|
|
|
679
|
+
|
|
680
|
+
|
|
681
|
+
|
|
682
|
+
|
|
627
683
|
|
|
628
684
|
|
|
629
685
|
|