data-structure-typed 2.6.1 → 2.6.2
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/CHANGELOG.md +9 -1
- package/dist/cjs/binary-tree.cjs +2927 -23688
- package/dist/cjs/graph.cjs +845 -2634
- package/dist/cjs/hash.cjs +185 -616
- package/dist/cjs/heap.cjs +266 -818
- package/dist/cjs/index.cjs +5116 -31358
- package/dist/cjs/linked-list.cjs +644 -2615
- package/dist/cjs/matrix.cjs +220 -535
- package/dist/cjs/priority-queue.cjs +266 -818
- package/dist/cjs/queue.cjs +637 -2343
- package/dist/cjs/stack.cjs +124 -530
- package/dist/cjs/trie.cjs +145 -592
- package/dist/cjs-legacy/binary-tree.cjs +4352 -25113
- package/dist/cjs-legacy/graph.cjs +847 -2636
- package/dist/cjs-legacy/hash.cjs +181 -612
- package/dist/cjs-legacy/heap.cjs +266 -818
- package/dist/cjs-legacy/index.cjs +6657 -32899
- package/dist/cjs-legacy/linked-list.cjs +640 -2611
- package/dist/cjs-legacy/matrix.cjs +220 -535
- package/dist/cjs-legacy/priority-queue.cjs +266 -818
- package/dist/cjs-legacy/queue.cjs +634 -2340
- package/dist/cjs-legacy/stack.cjs +124 -530
- package/dist/cjs-legacy/trie.cjs +145 -592
- package/dist/esm/binary-tree.mjs +2927 -23688
- package/dist/esm/graph.mjs +845 -2634
- package/dist/esm/hash.mjs +185 -616
- package/dist/esm/heap.mjs +266 -818
- package/dist/esm/index.mjs +5116 -31358
- package/dist/esm/linked-list.mjs +644 -2615
- package/dist/esm/matrix.mjs +220 -535
- package/dist/esm/priority-queue.mjs +266 -818
- package/dist/esm/queue.mjs +637 -2343
- package/dist/esm/stack.mjs +124 -530
- package/dist/esm/trie.mjs +145 -592
- package/dist/esm-legacy/binary-tree.mjs +4352 -25113
- package/dist/esm-legacy/graph.mjs +847 -2636
- package/dist/esm-legacy/hash.mjs +181 -612
- package/dist/esm-legacy/heap.mjs +266 -818
- package/dist/esm-legacy/index.mjs +6657 -32899
- package/dist/esm-legacy/linked-list.mjs +640 -2611
- package/dist/esm-legacy/matrix.mjs +220 -535
- package/dist/esm-legacy/priority-queue.mjs +266 -818
- package/dist/esm-legacy/queue.mjs +634 -2340
- package/dist/esm-legacy/stack.mjs +124 -530
- package/dist/esm-legacy/trie.mjs +145 -592
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +29 -500
- package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +38 -563
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +230 -1212
- package/dist/types/data-structures/binary-tree/bst.d.ts +124 -1063
- package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +99 -854
- package/dist/types/data-structures/binary-tree/segment-tree.d.ts +62 -314
- package/dist/types/data-structures/binary-tree/tree-map.d.ts +366 -5057
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +277 -4885
- package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +253 -3929
- package/dist/types/data-structures/binary-tree/tree-set.d.ts +261 -4782
- package/dist/types/data-structures/graph/abstract-graph.d.ts +44 -44
- package/dist/types/data-structures/graph/directed-graph.d.ts +130 -527
- package/dist/types/data-structures/graph/undirected-graph.d.ts +125 -482
- package/dist/types/data-structures/hash/hash-map.d.ts +132 -562
- package/dist/types/data-structures/heap/heap.d.ts +194 -746
- package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +120 -809
- package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +121 -733
- package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +193 -863
- package/dist/types/data-structures/matrix/matrix.d.ts +159 -474
- package/dist/types/data-structures/priority-queue/max-priority-queue.d.ts +1 -6
- package/dist/types/data-structures/priority-queue/min-priority-queue.d.ts +6 -11
- package/dist/types/data-structures/priority-queue/priority-queue.d.ts +1 -1
- package/dist/types/data-structures/queue/deque.d.ts +196 -804
- package/dist/types/data-structures/queue/queue.d.ts +99 -585
- package/dist/types/data-structures/stack/stack.d.ts +75 -481
- package/dist/types/data-structures/trie/trie.d.ts +98 -584
- package/dist/umd/data-structure-typed.js +6580 -32822
- package/dist/umd/data-structure-typed.min.js +3 -3
- package/docs-site-docusaurus/docs/api/classes/AVLTree.md +162 -215
- package/docs-site-docusaurus/docs/api/classes/AVLTreeNode.md +9 -9
- package/docs-site-docusaurus/docs/api/classes/AbstractGraph.md +47 -47
- package/docs-site-docusaurus/docs/api/classes/BST.md +155 -208
- package/docs-site-docusaurus/docs/api/classes/BSTNode.md +7 -7
- package/docs-site-docusaurus/docs/api/classes/BinaryIndexedTree.md +13 -29
- package/docs-site-docusaurus/docs/api/classes/BinaryTree.md +104 -158
- package/docs-site-docusaurus/docs/api/classes/BinaryTreeNode.md +13 -13
- package/docs-site-docusaurus/docs/api/classes/Deque.md +72 -104
- package/docs-site-docusaurus/docs/api/classes/DirectedGraph.md +60 -80
- package/docs-site-docusaurus/docs/api/classes/DoublyLinkedList.md +67 -101
- package/docs-site-docusaurus/docs/api/classes/DoublyLinkedListNode.md +6 -6
- package/docs-site-docusaurus/docs/api/classes/FibonacciHeap.md +9 -9
- package/docs-site-docusaurus/docs/api/classes/FibonacciHeapNode.md +1 -1
- package/docs-site-docusaurus/docs/api/classes/HashMap.md +52 -48
- package/docs-site-docusaurus/docs/api/classes/Heap.md +40 -68
- package/docs-site-docusaurus/docs/api/classes/IterableElementBase.md +17 -17
- package/docs-site-docusaurus/docs/api/classes/LinearBase.md +38 -38
- package/docs-site-docusaurus/docs/api/classes/LinearLinkedBase.md +45 -45
- package/docs-site-docusaurus/docs/api/classes/LinkedHashMap.md +23 -23
- package/docs-site-docusaurus/docs/api/classes/LinkedListQueue.md +68 -96
- package/docs-site-docusaurus/docs/api/classes/MapGraph.md +60 -80
- package/docs-site-docusaurus/docs/api/classes/Matrix.md +57 -52
- package/docs-site-docusaurus/docs/api/classes/MaxHeap.md +38 -66
- package/docs-site-docusaurus/docs/api/classes/MaxPriorityQueue.md +41 -74
- package/docs-site-docusaurus/docs/api/classes/MinHeap.md +38 -66
- package/docs-site-docusaurus/docs/api/classes/MinPriorityQueue.md +46 -79
- package/docs-site-docusaurus/docs/api/classes/PriorityQueue.md +40 -68
- package/docs-site-docusaurus/docs/api/classes/Queue.md +54 -78
- package/docs-site-docusaurus/docs/api/classes/RedBlackTree.md +171 -225
- package/docs-site-docusaurus/docs/api/classes/SegmentTree.md +10 -22
- package/docs-site-docusaurus/docs/api/classes/SinglyLinkedList.md +68 -98
- package/docs-site-docusaurus/docs/api/classes/SinglyLinkedListNode.md +4 -4
- package/docs-site-docusaurus/docs/api/classes/SkipList.md +98 -75
- package/docs-site-docusaurus/docs/api/classes/Stack.md +33 -53
- package/docs-site-docusaurus/docs/api/classes/TreeMap.md +104 -129
- package/docs-site-docusaurus/docs/api/classes/TreeMultiMap.md +57 -124
- package/docs-site-docusaurus/docs/api/classes/TreeSet.md +45 -116
- package/docs-site-docusaurus/docs/api/classes/Trie.md +37 -61
- package/docs-site-docusaurus/docs/api/classes/TrieNode.md +8 -8
- package/docs-site-docusaurus/docs/api/classes/UndirectedGraph.md +59 -77
- package/package.json +1 -1
- package/src/data-structures/binary-tree/tree-multi-set.ts +15 -11
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
# Class: BinaryTree\<K, V, R\>
|
|
8
8
|
|
|
9
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
9
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:271](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L271)
|
|
10
10
|
|
|
11
11
|
A general Binary Tree implementation.
|
|
12
12
|
|
|
@@ -128,7 +128,7 @@ The type of the raw data object (if using `toEntryFn`).
|
|
|
128
128
|
new BinaryTree<K, V, R>(keysNodesEntriesOrRaws?, options?): BinaryTree<K, V, R>;
|
|
129
129
|
```
|
|
130
130
|
|
|
131
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
131
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:288](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L288)
|
|
132
132
|
|
|
133
133
|
Creates an instance of BinaryTree.
|
|
134
134
|
|
|
@@ -176,7 +176,7 @@ IterableEntryBase<K, V | undefined>.constructor
|
|
|
176
176
|
get isDuplicate(): boolean;
|
|
177
177
|
```
|
|
178
178
|
|
|
179
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
179
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:326](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L326)
|
|
180
180
|
|
|
181
181
|
Gets whether the tree allows duplicate keys.
|
|
182
182
|
|
|
@@ -206,7 +206,7 @@ IBinaryTree.isDuplicate
|
|
|
206
206
|
get isMapMode(): boolean;
|
|
207
207
|
```
|
|
208
208
|
|
|
209
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
209
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:316](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L316)
|
|
210
210
|
|
|
211
211
|
Gets whether the tree is in Map mode.
|
|
212
212
|
|
|
@@ -266,7 +266,7 @@ IBinaryTree.NIL
|
|
|
266
266
|
get root(): BinaryTreeNode<K, V> | null | undefined;
|
|
267
267
|
```
|
|
268
268
|
|
|
269
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
269
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:351](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L351)
|
|
270
270
|
|
|
271
271
|
Gets the root node of the tree.
|
|
272
272
|
|
|
@@ -296,7 +296,7 @@ IBinaryTree.root
|
|
|
296
296
|
get size(): number;
|
|
297
297
|
```
|
|
298
298
|
|
|
299
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
299
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:363](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L363)
|
|
300
300
|
|
|
301
301
|
Gets the number of nodes in the tree.
|
|
302
302
|
|
|
@@ -330,7 +330,7 @@ IBinaryTree.size
|
|
|
330
330
|
get store(): Map<K, BinaryTreeNode<K, V>>;
|
|
331
331
|
```
|
|
332
332
|
|
|
333
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
333
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:339](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L339)
|
|
334
334
|
|
|
335
335
|
Gets the external value store (used in Map mode).
|
|
336
336
|
|
|
@@ -360,7 +360,7 @@ IBinaryTree.store
|
|
|
360
360
|
get toEntryFn(): ToEntryFn<K, V, R> | undefined;
|
|
361
361
|
```
|
|
362
362
|
|
|
363
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
363
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:383](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L383)
|
|
364
364
|
|
|
365
365
|
Gets the function used to convert raw data objects (R) into [key, value] entries.
|
|
366
366
|
|
|
@@ -426,7 +426,7 @@ IBinaryTree.[iterator]
|
|
|
426
426
|
add(keyNodeOrEntry): boolean;
|
|
427
427
|
```
|
|
428
428
|
|
|
429
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
429
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:609](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L609)
|
|
430
430
|
|
|
431
431
|
Adds a new node to the tree.
|
|
432
432
|
|
|
@@ -448,8 +448,6 @@ The key, node, or entry to add.
|
|
|
448
448
|
|
|
449
449
|
True if the addition was successful, false otherwise.
|
|
450
450
|
|
|
451
|
-
*
|
|
452
|
-
|
|
453
451
|
#### Remarks
|
|
454
452
|
|
|
455
453
|
Time O(N) — level-order traversal to find an empty slot. Space O(N) for the BFS queue. BST/Red-Black Tree/AVL Tree subclasses override to O(log N).
|
|
@@ -480,7 +478,7 @@ IBinaryTree.add
|
|
|
480
478
|
addMany(keysNodesEntriesOrRaws): boolean[];
|
|
481
479
|
```
|
|
482
480
|
|
|
483
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
481
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:711](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L711)
|
|
484
482
|
|
|
485
483
|
Adds multiple items to the tree.
|
|
486
484
|
|
|
@@ -504,8 +502,6 @@ An iterable of items to set.
|
|
|
504
502
|
|
|
505
503
|
An array of booleans indicating the success of each individual `set` operation.
|
|
506
504
|
|
|
507
|
-
*
|
|
508
|
-
|
|
509
505
|
#### Remarks
|
|
510
506
|
|
|
511
507
|
Time O(N * M), where N is the number of items to set and M is the size of the tree at insertion (due to O(M) `set` operation). Space O(M) (from `set`) + O(N) (for the `inserted` array).
|
|
@@ -561,12 +557,10 @@ If true, includes null nodes in the traversal.
|
|
|
561
557
|
bfs(): (K | undefined)[];
|
|
562
558
|
```
|
|
563
559
|
|
|
564
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
560
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1563](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L1563)
|
|
565
561
|
|
|
566
562
|
BinaryTree level-order traversal
|
|
567
563
|
|
|
568
|
-
*
|
|
569
|
-
|
|
570
564
|
##### Returns
|
|
571
565
|
|
|
572
566
|
(`K` \| `undefined`)[]
|
|
@@ -618,12 +612,10 @@ bfs<C>(
|
|
|
618
612
|
includeNull?): ReturnType<C>[];
|
|
619
613
|
```
|
|
620
614
|
|
|
621
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
615
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1565](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L1565)
|
|
622
616
|
|
|
623
617
|
BinaryTree level-order traversal
|
|
624
618
|
|
|
625
|
-
*
|
|
626
|
-
|
|
627
619
|
##### Type Parameters
|
|
628
620
|
|
|
629
621
|
###### C
|
|
@@ -702,12 +694,10 @@ bfs<C>(
|
|
|
702
694
|
includeNull?): ReturnType<C>[];
|
|
703
695
|
```
|
|
704
696
|
|
|
705
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
697
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1572](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L1572)
|
|
706
698
|
|
|
707
699
|
BinaryTree level-order traversal
|
|
708
700
|
|
|
709
|
-
*
|
|
710
|
-
|
|
711
701
|
##### Type Parameters
|
|
712
702
|
|
|
713
703
|
###### C
|
|
@@ -784,7 +774,7 @@ IBinaryTree.bfs
|
|
|
784
774
|
clear(): void;
|
|
785
775
|
```
|
|
786
776
|
|
|
787
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
777
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1087](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L1087)
|
|
788
778
|
|
|
789
779
|
Clears the tree of all nodes and values.
|
|
790
780
|
|
|
@@ -796,8 +786,6 @@ Clears the tree of all nodes and values.
|
|
|
796
786
|
|
|
797
787
|
Time O(N) if in Map mode (due to `_store.clear()`), O(1) otherwise. Space O(1)
|
|
798
788
|
|
|
799
|
-
*
|
|
800
|
-
|
|
801
789
|
#### Example
|
|
802
790
|
|
|
803
791
|
```ts
|
|
@@ -825,7 +813,7 @@ IBinaryTree.clear
|
|
|
825
813
|
clone(): this;
|
|
826
814
|
```
|
|
827
815
|
|
|
828
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
816
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1939](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L1939)
|
|
829
817
|
|
|
830
818
|
Clones the tree.
|
|
831
819
|
|
|
@@ -835,8 +823,6 @@ Clones the tree.
|
|
|
835
823
|
|
|
836
824
|
A new, cloned instance of the tree.
|
|
837
825
|
|
|
838
|
-
*
|
|
839
|
-
|
|
840
826
|
#### Remarks
|
|
841
827
|
|
|
842
828
|
Time O(N * M), where N is the number of nodes and M is the tree size during insertion (due to `bfs` + `set`, and `set` is O(M)). Space O(N) for the new tree and the BFS queue.
|
|
@@ -869,7 +855,7 @@ IBinaryTree.clone
|
|
|
869
855
|
createNode(key, value?): BinaryTreeNode<K, V>;
|
|
870
856
|
```
|
|
871
857
|
|
|
872
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
858
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:428](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L428)
|
|
873
859
|
|
|
874
860
|
(Protected) Creates a new node.
|
|
875
861
|
|
|
@@ -911,7 +897,7 @@ IBinaryTree.createNode
|
|
|
911
897
|
createTree(options?): this;
|
|
912
898
|
```
|
|
913
899
|
|
|
914
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
900
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:439](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L439)
|
|
915
901
|
|
|
916
902
|
Creates a new, empty tree of the same type and configuration.
|
|
917
903
|
|
|
@@ -947,7 +933,7 @@ IBinaryTree.createTree
|
|
|
947
933
|
delete(keyNodeEntryRawOrPredicate): boolean;
|
|
948
934
|
```
|
|
949
935
|
|
|
950
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
936
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:794](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L794)
|
|
951
937
|
|
|
952
938
|
Deletes a node from the tree.
|
|
953
939
|
|
|
@@ -966,8 +952,6 @@ The node to delete.
|
|
|
966
952
|
|
|
967
953
|
True if the node was found and deleted, false otherwise.
|
|
968
954
|
|
|
969
|
-
*
|
|
970
|
-
|
|
971
955
|
#### Remarks
|
|
972
956
|
|
|
973
957
|
Time O(N) — O(N) to find the node + O(H) for predecessor swap. Space O(1). BST/Red-Black Tree/AVL Tree subclasses override to O(log N).
|
|
@@ -1032,12 +1016,10 @@ If true, includes null nodes in the traversal.
|
|
|
1032
1016
|
dfs(): (K | undefined)[];
|
|
1033
1017
|
```
|
|
1034
1018
|
|
|
1035
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
1019
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1488](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L1488)
|
|
1036
1020
|
|
|
1037
1021
|
Depth-first search traversal
|
|
1038
1022
|
|
|
1039
|
-
*
|
|
1040
|
-
|
|
1041
1023
|
##### Returns
|
|
1042
1024
|
|
|
1043
1025
|
(`K` \| `undefined`)[]
|
|
@@ -1068,12 +1050,10 @@ dfs<C>(
|
|
|
1068
1050
|
iterationType?): ReturnType<C>[];
|
|
1069
1051
|
```
|
|
1070
1052
|
|
|
1071
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
1053
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1490](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L1490)
|
|
1072
1054
|
|
|
1073
1055
|
Depth-first search traversal
|
|
1074
1056
|
|
|
1075
|
-
*
|
|
1076
|
-
|
|
1077
1057
|
##### Type Parameters
|
|
1078
1058
|
|
|
1079
1059
|
###### C
|
|
@@ -1136,12 +1116,10 @@ dfs<C>(
|
|
|
1136
1116
|
includeNull?): ReturnType<C>[];
|
|
1137
1117
|
```
|
|
1138
1118
|
|
|
1139
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
1119
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1498](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L1498)
|
|
1140
1120
|
|
|
1141
1121
|
Depth-first search traversal
|
|
1142
1122
|
|
|
1143
|
-
*
|
|
1144
|
-
|
|
1145
1123
|
##### Type Parameters
|
|
1146
1124
|
|
|
1147
1125
|
###### C
|
|
@@ -1204,7 +1182,7 @@ IBinaryTree.dfs
|
|
|
1204
1182
|
ensureNode(keyNodeOrEntry, iterationType?): BinaryTreeNode<K, V> | null | undefined;
|
|
1205
1183
|
```
|
|
1206
1184
|
|
|
1207
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
1185
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:451](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L451)
|
|
1208
1186
|
|
|
1209
1187
|
Ensures the input is a node. If it's a key or entry, it searches for the node.
|
|
1210
1188
|
|
|
@@ -1322,7 +1300,7 @@ IBinaryTree.every
|
|
|
1322
1300
|
filter(predicate, thisArg?): this;
|
|
1323
1301
|
```
|
|
1324
1302
|
|
|
1325
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
1303
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1958](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L1958)
|
|
1326
1304
|
|
|
1327
1305
|
Creates a new tree containing only the entries that satisfy the predicate.
|
|
1328
1306
|
|
|
@@ -1346,8 +1324,6 @@ A function to test each [key, value] pair.
|
|
|
1346
1324
|
|
|
1347
1325
|
A new, filtered tree.
|
|
1348
1326
|
|
|
1349
|
-
*
|
|
1350
|
-
|
|
1351
1327
|
#### Remarks
|
|
1352
1328
|
|
|
1353
1329
|
Time O(N * M), where N is nodes in this tree, and M is size of the new tree during insertion (O(N) iteration + O(M) `set` for each item). Space O(N) for the new tree.
|
|
@@ -1472,7 +1448,7 @@ get(
|
|
|
1472
1448
|
iterationType?): V | undefined;
|
|
1473
1449
|
```
|
|
1474
1450
|
|
|
1475
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
1451
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:995](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L995)
|
|
1476
1452
|
|
|
1477
1453
|
Gets the value associated with a key.
|
|
1478
1454
|
|
|
@@ -1509,8 +1485,6 @@ The traversal method (if not in Map mode).
|
|
|
1509
1485
|
|
|
1510
1486
|
The associated value, or undefined.
|
|
1511
1487
|
|
|
1512
|
-
*
|
|
1513
|
-
|
|
1514
1488
|
#### Remarks
|
|
1515
1489
|
|
|
1516
1490
|
Time O(1) in Map mode, O(N) otherwise (via `getNode`). Space O(1) in Map mode, O(H) or O(N) otherwise. BST subclasses override non-Map-mode to O(log N).
|
|
@@ -1519,7 +1493,11 @@ Time O(1) in Map mode, O(N) otherwise (via `getNode`). Space O(1) in Map mode, O
|
|
|
1519
1493
|
|
|
1520
1494
|
```ts
|
|
1521
1495
|
// Retrieve value by key
|
|
1522
|
-
const tree = new BinaryTree<number, string>([
|
|
1496
|
+
const tree = new BinaryTree<number, string>([
|
|
1497
|
+
[1, 'root'],
|
|
1498
|
+
[2, 'left'],
|
|
1499
|
+
[3, 'right']
|
|
1500
|
+
]);
|
|
1523
1501
|
console.log(tree.get(2)); // 'left';
|
|
1524
1502
|
console.log(tree.get(99)); // undefined;
|
|
1525
1503
|
```
|
|
@@ -1542,7 +1520,7 @@ IBinaryTree.get
|
|
|
1542
1520
|
getDepth(dist, startNode?): number;
|
|
1543
1521
|
```
|
|
1544
1522
|
|
|
1545
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
1523
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1187](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L1187)
|
|
1546
1524
|
|
|
1547
1525
|
Gets the depth of a node (distance from `startNode`).
|
|
1548
1526
|
|
|
@@ -1573,8 +1551,6 @@ The node to measure depth from (defaults to root).
|
|
|
1573
1551
|
|
|
1574
1552
|
The depth (0 if `dist` is `startNode`).
|
|
1575
1553
|
|
|
1576
|
-
*
|
|
1577
|
-
|
|
1578
1554
|
#### Remarks
|
|
1579
1555
|
|
|
1580
1556
|
Time O(H), where H is the depth of the `dist` node relative to `startNode`. O(N) worst-case. Space O(1).
|
|
@@ -1602,7 +1578,7 @@ IBinaryTree.getDepth
|
|
|
1602
1578
|
getHeight(startNode?, iterationType?): number;
|
|
1603
1579
|
```
|
|
1604
1580
|
|
|
1605
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
1581
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1216](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L1216)
|
|
1606
1582
|
|
|
1607
1583
|
Gets the maximum height of the tree (longest path from startNode to a leaf).
|
|
1608
1584
|
|
|
@@ -1629,8 +1605,6 @@ The traversal method.
|
|
|
1629
1605
|
|
|
1630
1606
|
The height ( -1 for an empty tree, 0 for a single-node tree).
|
|
1631
1607
|
|
|
1632
|
-
*
|
|
1633
|
-
|
|
1634
1608
|
#### Remarks
|
|
1635
1609
|
|
|
1636
1610
|
Time O(N), as it must visit every node. Space O(H) for recursive stack (O(N) worst-case) or O(N) for iterative stack (storing node + depth).
|
|
@@ -1681,7 +1655,7 @@ The traversal method.
|
|
|
1681
1655
|
getLeftMost(): K | undefined;
|
|
1682
1656
|
```
|
|
1683
1657
|
|
|
1684
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
1658
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1343](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L1343)
|
|
1685
1659
|
|
|
1686
1660
|
##### Returns
|
|
1687
1661
|
|
|
@@ -1702,7 +1676,7 @@ getLeftMost<C>(
|
|
|
1702
1676
|
iterationType?): ReturnType<C>;
|
|
1703
1677
|
```
|
|
1704
1678
|
|
|
1705
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
1679
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1345](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L1345)
|
|
1706
1680
|
|
|
1707
1681
|
##### Type Parameters
|
|
1708
1682
|
|
|
@@ -1745,7 +1719,7 @@ IBinaryTree.getLeftMost
|
|
|
1745
1719
|
getMinHeight(startNode?, iterationType?): number;
|
|
1746
1720
|
```
|
|
1747
1721
|
|
|
1748
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
1722
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1258](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L1258)
|
|
1749
1723
|
|
|
1750
1724
|
Gets the minimum height of the tree (shortest path from startNode to a leaf).
|
|
1751
1725
|
|
|
@@ -1793,7 +1767,7 @@ getNode(
|
|
|
1793
1767
|
iterationType?): BinaryTreeNode<K, V> | null | undefined;
|
|
1794
1768
|
```
|
|
1795
1769
|
|
|
1796
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
1770
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:956](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L956)
|
|
1797
1771
|
|
|
1798
1772
|
Gets the first node matching a predicate.
|
|
1799
1773
|
|
|
@@ -1831,8 +1805,6 @@ The traversal method.
|
|
|
1831
1805
|
|
|
1832
1806
|
The first matching node, or undefined if not found.
|
|
1833
1807
|
|
|
1834
|
-
*
|
|
1835
|
-
|
|
1836
1808
|
#### Remarks
|
|
1837
1809
|
|
|
1838
1810
|
Time O(N) via `search`. Space O(H) or O(N). BST/Red-Black Tree/AVL Tree subclasses override to O(log N) for key lookups.
|
|
@@ -1841,7 +1813,10 @@ Time O(N) via `search`. Space O(H) or O(N). BST/Red-Black Tree/AVL Tree subclass
|
|
|
1841
1813
|
|
|
1842
1814
|
```ts
|
|
1843
1815
|
// Get node by key
|
|
1844
|
-
const tree = new BinaryTree<number, string>([
|
|
1816
|
+
const tree = new BinaryTree<number, string>([
|
|
1817
|
+
[1, 'root'],
|
|
1818
|
+
[2, 'child']
|
|
1819
|
+
]);
|
|
1845
1820
|
console.log(tree.getNode(2)?.value); // 'child';
|
|
1846
1821
|
```
|
|
1847
1822
|
|
|
@@ -1863,7 +1838,7 @@ getNodes(
|
|
|
1863
1838
|
iterationType?): BinaryTreeNode<K, V>[];
|
|
1864
1839
|
```
|
|
1865
1840
|
|
|
1866
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
1841
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:912](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L912)
|
|
1867
1842
|
|
|
1868
1843
|
Gets all nodes matching a predicate.
|
|
1869
1844
|
|
|
@@ -1907,8 +1882,6 @@ The traversal method.
|
|
|
1907
1882
|
|
|
1908
1883
|
An array of matching nodes.
|
|
1909
1884
|
|
|
1910
|
-
*
|
|
1911
|
-
|
|
1912
1885
|
#### Remarks
|
|
1913
1886
|
|
|
1914
1887
|
Time O(N) (via `search`). Space O(H) or O(N) (via `search`).
|
|
@@ -1954,7 +1927,7 @@ If true, returns the path from root-to-node.
|
|
|
1954
1927
|
getPathToRoot(beginNode): (K | undefined)[];
|
|
1955
1928
|
```
|
|
1956
1929
|
|
|
1957
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
1930
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1305](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L1305)
|
|
1958
1931
|
|
|
1959
1932
|
##### Parameters
|
|
1960
1933
|
|
|
@@ -1985,7 +1958,7 @@ getPathToRoot<C>(
|
|
|
1985
1958
|
isReverse?): ReturnType<C>[];
|
|
1986
1959
|
```
|
|
1987
1960
|
|
|
1988
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
1961
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1309](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L1309)
|
|
1989
1962
|
|
|
1990
1963
|
##### Type Parameters
|
|
1991
1964
|
|
|
@@ -2029,7 +2002,7 @@ IBinaryTree.getPathToRoot
|
|
|
2029
2002
|
getPredecessor(node): BinaryTreeNode<K, V>;
|
|
2030
2003
|
```
|
|
2031
2004
|
|
|
2032
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2005
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1443](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L1443)
|
|
2033
2006
|
|
|
2034
2007
|
Gets the Morris traversal predecessor (rightmost node in the left subtree, or node itself).
|
|
2035
2008
|
|
|
@@ -2083,7 +2056,7 @@ The traversal method.
|
|
|
2083
2056
|
getRightMost(): K | undefined;
|
|
2084
2057
|
```
|
|
2085
2058
|
|
|
2086
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2059
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1390](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L1390)
|
|
2087
2060
|
|
|
2088
2061
|
##### Returns
|
|
2089
2062
|
|
|
@@ -2104,7 +2077,7 @@ getRightMost<C>(
|
|
|
2104
2077
|
iterationType?): ReturnType<C>;
|
|
2105
2078
|
```
|
|
2106
2079
|
|
|
2107
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2080
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1392](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L1392)
|
|
2108
2081
|
|
|
2109
2082
|
##### Type Parameters
|
|
2110
2083
|
|
|
@@ -2147,7 +2120,7 @@ IBinaryTree.getRightMost
|
|
|
2147
2120
|
getSuccessor(x?): BinaryTreeNode<K, V> | null | undefined;
|
|
2148
2121
|
```
|
|
2149
2122
|
|
|
2150
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2123
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1464](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L1464)
|
|
2151
2124
|
|
|
2152
2125
|
Gets the in-order successor of a node in a BST.
|
|
2153
2126
|
|
|
@@ -2180,7 +2153,7 @@ has(
|
|
|
2180
2153
|
iterationType?): boolean;
|
|
2181
2154
|
```
|
|
2182
2155
|
|
|
2183
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2156
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1045](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L1045)
|
|
2184
2157
|
|
|
2185
2158
|
Checks if a node matching the predicate exists in the tree.
|
|
2186
2159
|
|
|
@@ -2217,8 +2190,6 @@ The traversal method.
|
|
|
2217
2190
|
|
|
2218
2191
|
True if a matching node exists, false otherwise.
|
|
2219
2192
|
|
|
2220
|
-
*
|
|
2221
|
-
|
|
2222
2193
|
#### Remarks
|
|
2223
2194
|
|
|
2224
2195
|
Time O(N) via `search`. Space O(H) or O(N). BST/Red-Black Tree/AVL Tree subclasses override to O(log N) for key lookups.
|
|
@@ -2313,7 +2284,7 @@ IBinaryTree.hasValue
|
|
|
2313
2284
|
isBST(startNode?, iterationType?): boolean;
|
|
2314
2285
|
```
|
|
2315
2286
|
|
|
2316
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2287
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1131](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L1131)
|
|
2317
2288
|
|
|
2318
2289
|
Checks if the tree is a valid Binary Search Tree (BST).
|
|
2319
2290
|
|
|
@@ -2340,8 +2311,6 @@ The traversal method.
|
|
|
2340
2311
|
|
|
2341
2312
|
True if it's a valid BST, false otherwise.
|
|
2342
2313
|
|
|
2343
|
-
*
|
|
2344
|
-
|
|
2345
2314
|
#### Remarks
|
|
2346
2315
|
|
|
2347
2316
|
Time O(N), as it must visit every node. Space O(H) for the call stack (recursive) or explicit stack (iterative), where H is the tree height (O(N) worst-case).
|
|
@@ -2369,7 +2338,7 @@ IBinaryTree.isBST
|
|
|
2369
2338
|
isEmpty(): boolean;
|
|
2370
2339
|
```
|
|
2371
2340
|
|
|
2372
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2341
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1101](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L1101)
|
|
2373
2342
|
|
|
2374
2343
|
Checks if the tree is empty.
|
|
2375
2344
|
|
|
@@ -2379,8 +2348,6 @@ Checks if the tree is empty.
|
|
|
2379
2348
|
|
|
2380
2349
|
True if the tree has no nodes, false otherwise.
|
|
2381
2350
|
|
|
2382
|
-
*
|
|
2383
|
-
|
|
2384
2351
|
#### Remarks
|
|
2385
2352
|
|
|
2386
2353
|
Time O(1), Space O(1)
|
|
@@ -2410,7 +2377,7 @@ IBinaryTree.isEmpty
|
|
|
2410
2377
|
isEntry(keyNodeOrEntry): keyNodeOrEntry is BTNEntry<K, V>;
|
|
2411
2378
|
```
|
|
2412
2379
|
|
|
2413
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2380
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:576](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L576)
|
|
2414
2381
|
|
|
2415
2382
|
Checks if the given item is a [key, value] entry pair.
|
|
2416
2383
|
|
|
@@ -2444,7 +2411,7 @@ Time O(1), Space O(1)
|
|
|
2444
2411
|
isLeaf(keyNodeOrEntry): boolean;
|
|
2445
2412
|
```
|
|
2446
2413
|
|
|
2447
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2414
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:562](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L562)
|
|
2448
2415
|
|
|
2449
2416
|
Checks if a node is a leaf (has no real children).
|
|
2450
2417
|
|
|
@@ -2478,7 +2445,7 @@ Time O(N) if a key/entry is passed (due to `ensureNode`). O(1) if a node is pass
|
|
|
2478
2445
|
isNIL(keyNodeOrEntry): boolean;
|
|
2479
2446
|
```
|
|
2480
2447
|
|
|
2481
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2448
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:531](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L531)
|
|
2482
2449
|
|
|
2483
2450
|
Checks if the given item is the sentinel NIL node.
|
|
2484
2451
|
|
|
@@ -2512,7 +2479,7 @@ Time O(1), Space O(1)
|
|
|
2512
2479
|
isNode(keyNodeOrEntry): keyNodeOrEntry is BinaryTreeNode<K, V>;
|
|
2513
2480
|
```
|
|
2514
2481
|
|
|
2515
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2482
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:478](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L478)
|
|
2516
2483
|
|
|
2517
2484
|
Checks if the given item is a `BinaryTreeNode` instance.
|
|
2518
2485
|
|
|
@@ -2546,7 +2513,7 @@ Time O(1), Space O(1)
|
|
|
2546
2513
|
isPerfectlyBalanced(startNode?): boolean;
|
|
2547
2514
|
```
|
|
2548
2515
|
|
|
2549
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2516
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1112](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L1112)
|
|
2550
2517
|
|
|
2551
2518
|
Checks if the tree is perfectly balanced.
|
|
2552
2519
|
|
|
@@ -2585,7 +2552,7 @@ IBinaryTree.isPerfectlyBalanced
|
|
|
2585
2552
|
isRange(keyNodeEntryOrPredicate): keyNodeEntryOrPredicate is Range<K>;
|
|
2586
2553
|
```
|
|
2587
2554
|
|
|
2588
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2555
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:542](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L542)
|
|
2589
2556
|
|
|
2590
2557
|
Checks if the given item is a `Range` object.
|
|
2591
2558
|
|
|
@@ -2621,7 +2588,7 @@ Time O(1), Space O(1)
|
|
|
2621
2588
|
isRaw(keyNodeEntryOrRaw): keyNodeEntryOrRaw is R;
|
|
2622
2589
|
```
|
|
2623
2590
|
|
|
2624
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2591
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:491](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L491)
|
|
2625
2592
|
|
|
2626
2593
|
Checks if the given item is a raw data object (R) that needs conversion via `toEntryFn`.
|
|
2627
2594
|
|
|
@@ -2656,7 +2623,7 @@ Time O(1), Space O(1)
|
|
|
2656
2623
|
isRealNode(keyNodeOrEntry): keyNodeOrEntry is BinaryTreeNode<K, V>;
|
|
2657
2624
|
```
|
|
2658
2625
|
|
|
2659
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2626
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:504](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L504)
|
|
2660
2627
|
|
|
2661
2628
|
Checks if the given item is a "real" node (i.e., not null, undefined, or NIL).
|
|
2662
2629
|
|
|
@@ -2690,7 +2657,7 @@ Time O(1), Space O(1)
|
|
|
2690
2657
|
isRealNodeOrNull(keyNodeOrEntry): keyNodeOrEntry is BinaryTreeNode<K, V> | null;
|
|
2691
2658
|
```
|
|
2692
2659
|
|
|
2693
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2660
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:518](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L518)
|
|
2694
2661
|
|
|
2695
2662
|
Checks if the given item is either a "real" node or null.
|
|
2696
2663
|
|
|
@@ -2724,7 +2691,7 @@ Time O(1), Space O(1)
|
|
|
2724
2691
|
isValidKey(key): key is K;
|
|
2725
2692
|
```
|
|
2726
2693
|
|
|
2727
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2694
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:589](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L589)
|
|
2728
2695
|
|
|
2729
2696
|
Checks if the given key is valid (comparable or null).
|
|
2730
2697
|
|
|
@@ -2810,12 +2777,10 @@ The traversal method.
|
|
|
2810
2777
|
leaves(): (K | undefined)[];
|
|
2811
2778
|
```
|
|
2812
2779
|
|
|
2813
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2780
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1655](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L1655)
|
|
2814
2781
|
|
|
2815
2782
|
Get leaf nodes
|
|
2816
2783
|
|
|
2817
|
-
*
|
|
2818
|
-
|
|
2819
2784
|
##### Returns
|
|
2820
2785
|
|
|
2821
2786
|
(`K` \| `undefined`)[]
|
|
@@ -2844,12 +2809,10 @@ leaves<C>(
|
|
|
2844
2809
|
iterationType?): ReturnType<C>[];
|
|
2845
2810
|
```
|
|
2846
2811
|
|
|
2847
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2812
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1657](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L1657)
|
|
2848
2813
|
|
|
2849
2814
|
Get leaf nodes
|
|
2850
2815
|
|
|
2851
|
-
*
|
|
2852
|
-
|
|
2853
2816
|
##### Type Parameters
|
|
2854
2817
|
|
|
2855
2818
|
###### C
|
|
@@ -2928,12 +2891,10 @@ If true, includes null nodes.
|
|
|
2928
2891
|
listLevels(): (K | undefined)[][];
|
|
2929
2892
|
```
|
|
2930
2893
|
|
|
2931
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2894
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1724](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L1724)
|
|
2932
2895
|
|
|
2933
2896
|
Level-order grouping
|
|
2934
2897
|
|
|
2935
|
-
*
|
|
2936
|
-
|
|
2937
2898
|
##### Returns
|
|
2938
2899
|
|
|
2939
2900
|
(`K` \| `undefined`)[][]
|
|
@@ -2964,12 +2925,10 @@ listLevels<C>(
|
|
|
2964
2925
|
includeNull?): ReturnType<C>[][];
|
|
2965
2926
|
```
|
|
2966
2927
|
|
|
2967
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2928
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1726](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L1726)
|
|
2968
2929
|
|
|
2969
2930
|
Level-order grouping
|
|
2970
2931
|
|
|
2971
|
-
*
|
|
2972
|
-
|
|
2973
2932
|
##### Type Parameters
|
|
2974
2933
|
|
|
2975
2934
|
###### C
|
|
@@ -3027,12 +2986,10 @@ listLevels<C>(
|
|
|
3027
2986
|
includeNull?): ReturnType<C>[][];
|
|
3028
2987
|
```
|
|
3029
2988
|
|
|
3030
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2989
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1733](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L1733)
|
|
3031
2990
|
|
|
3032
2991
|
Level-order grouping
|
|
3033
2992
|
|
|
3034
|
-
*
|
|
3035
|
-
|
|
3036
2993
|
##### Type Parameters
|
|
3037
2994
|
|
|
3038
2995
|
###### C
|
|
@@ -3091,7 +3048,7 @@ map<MK, MV, MR>(
|
|
|
3091
3048
|
thisArg?): BinaryTree<MK, MV, MR>;
|
|
3092
3049
|
```
|
|
3093
3050
|
|
|
3094
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
3051
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1985](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L1985)
|
|
3095
3052
|
|
|
3096
3053
|
Creates a new tree by mapping each [key, value] pair to a new entry.
|
|
3097
3054
|
|
|
@@ -3141,8 +3098,6 @@ Options for the new tree.
|
|
|
3141
3098
|
|
|
3142
3099
|
A new, mapped tree.
|
|
3143
3100
|
|
|
3144
|
-
*
|
|
3145
|
-
|
|
3146
3101
|
#### Remarks
|
|
3147
3102
|
|
|
3148
3103
|
Time O(N * M), where N is nodes in this tree, and M is size of the new tree during insertion. Space O(N) for the new tree.
|
|
@@ -3151,7 +3106,10 @@ Time O(N * M), where N is nodes in this tree, and M is size of the new tree duri
|
|
|
3151
3106
|
|
|
3152
3107
|
```ts
|
|
3153
3108
|
// Transform to new tree
|
|
3154
|
-
const tree = new BinaryTree<number, number>([
|
|
3109
|
+
const tree = new BinaryTree<number, number>([
|
|
3110
|
+
[1, 10],
|
|
3111
|
+
[2, 20]
|
|
3112
|
+
]);
|
|
3155
3113
|
const mapped = tree.map((v, key) => [key, (v ?? 0) + 1] as [number, number]);
|
|
3156
3114
|
console.log([...mapped.values()]); // contains 11;
|
|
3157
3115
|
```
|
|
@@ -3174,7 +3132,7 @@ IBinaryTree.map
|
|
|
3174
3132
|
merge(anotherTree): void;
|
|
3175
3133
|
```
|
|
3176
3134
|
|
|
3177
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
3135
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:777](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L777)
|
|
3178
3136
|
|
|
3179
3137
|
Merges another tree into this one by seting all its nodes.
|
|
3180
3138
|
|
|
@@ -3186,8 +3144,6 @@ Merges another tree into this one by seting all its nodes.
|
|
|
3186
3144
|
|
|
3187
3145
|
The tree to merge.
|
|
3188
3146
|
|
|
3189
|
-
*
|
|
3190
|
-
|
|
3191
3147
|
#### Returns
|
|
3192
3148
|
|
|
3193
3149
|
`void`
|
|
@@ -3244,12 +3200,10 @@ The node to start from.
|
|
|
3244
3200
|
morris(): (K | undefined)[];
|
|
3245
3201
|
```
|
|
3246
3202
|
|
|
3247
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
3203
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1809](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L1809)
|
|
3248
3204
|
|
|
3249
3205
|
Morris traversal (O(1) space)
|
|
3250
3206
|
|
|
3251
|
-
*
|
|
3252
|
-
|
|
3253
3207
|
##### Returns
|
|
3254
3208
|
|
|
3255
3209
|
(`K` \| `undefined`)[]
|
|
@@ -3278,12 +3232,10 @@ morris<C>(
|
|
|
3278
3232
|
startNode?): ReturnType<C>[];
|
|
3279
3233
|
```
|
|
3280
3234
|
|
|
3281
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
3235
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1811](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L1811)
|
|
3282
3236
|
|
|
3283
3237
|
Morris traversal (O(1) space)
|
|
3284
3238
|
|
|
3285
|
-
*
|
|
3286
|
-
|
|
3287
3239
|
##### Type Parameters
|
|
3288
3240
|
|
|
3289
3241
|
###### C
|
|
@@ -3334,7 +3286,7 @@ IBinaryTree.morris
|
|
|
3334
3286
|
print(options?, startNode?): void;
|
|
3335
3287
|
```
|
|
3336
3288
|
|
|
3337
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
3289
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:2041](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L2041)
|
|
3338
3290
|
|
|
3339
3291
|
Prints a visual representation of the tree to the console.
|
|
3340
3292
|
|
|
@@ -3355,8 +3307,6 @@ Options to control the output.
|
|
|
3355
3307
|
|
|
3356
3308
|
The node to start printing from.
|
|
3357
3309
|
|
|
3358
|
-
*
|
|
3359
|
-
|
|
3360
3310
|
#### Returns
|
|
3361
3311
|
|
|
3362
3312
|
`void`
|
|
@@ -3469,12 +3419,10 @@ Whether to use 'RECURSIVE' or 'ITERATIVE' search.
|
|
|
3469
3419
|
search(keyNodeEntryOrPredicate, onlyOne?): (K | undefined)[];
|
|
3470
3420
|
```
|
|
3471
3421
|
|
|
3472
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
3422
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:808](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L808)
|
|
3473
3423
|
|
|
3474
3424
|
Search by predicate
|
|
3475
3425
|
|
|
3476
|
-
*
|
|
3477
|
-
|
|
3478
3426
|
##### Parameters
|
|
3479
3427
|
|
|
3480
3428
|
###### keyNodeEntryOrPredicate
|
|
@@ -3520,12 +3468,10 @@ search<C>(
|
|
|
3520
3468
|
iterationType?): ReturnType<C>[];
|
|
3521
3469
|
```
|
|
3522
3470
|
|
|
3523
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
3471
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:819](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L819)
|
|
3524
3472
|
|
|
3525
3473
|
Search by predicate
|
|
3526
3474
|
|
|
3527
|
-
*
|
|
3528
|
-
|
|
3529
3475
|
##### Type Parameters
|
|
3530
3476
|
|
|
3531
3477
|
###### C
|
|
@@ -3589,7 +3535,7 @@ IBinaryTree.search
|
|
|
3589
3535
|
set(keyNodeOrEntry, value?): boolean;
|
|
3590
3536
|
```
|
|
3591
3537
|
|
|
3592
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
3538
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:644](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L644)
|
|
3593
3539
|
|
|
3594
3540
|
Adds or updates a new node to the tree.
|
|
3595
3541
|
|
|
@@ -3617,8 +3563,6 @@ The value, if providing just a key.
|
|
|
3617
3563
|
|
|
3618
3564
|
True if the addition was successful, false otherwise.
|
|
3619
3565
|
|
|
3620
|
-
*
|
|
3621
|
-
|
|
3622
3566
|
#### Remarks
|
|
3623
3567
|
|
|
3624
3568
|
Time O(N) — level-order traversal to find an empty slot. Space O(N) for the BFS queue. BST/Red-Black Tree/AVL Tree subclasses override to O(log N).
|
|
@@ -3664,7 +3608,7 @@ IBinaryTree.set
|
|
|
3664
3608
|
setMany(keysNodesEntriesOrRaws, values?): boolean[];
|
|
3665
3609
|
```
|
|
3666
3610
|
|
|
3667
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
3611
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:736](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L736)
|
|
3668
3612
|
|
|
3669
3613
|
Adds or updates multiple items to the tree.
|
|
3670
3614
|
|
|
@@ -3694,8 +3638,6 @@ An optional parallel iterable of values.
|
|
|
3694
3638
|
|
|
3695
3639
|
An array of booleans indicating the success of each individual `set` operation.
|
|
3696
3640
|
|
|
3697
|
-
*
|
|
3698
|
-
|
|
3699
3641
|
#### Remarks
|
|
3700
3642
|
|
|
3701
3643
|
Time O(N * M), where N is the number of items to set and M is the size of the tree at insertion (due to O(M) `set` operation). Space O(M) (from `set`) + O(N) (for the `inserted` array).
|
|
@@ -3705,7 +3647,11 @@ Time O(N * M), where N is the number of items to set and M is the size of the tr
|
|
|
3705
3647
|
```ts
|
|
3706
3648
|
// Set multiple entries
|
|
3707
3649
|
const tree = new BinaryTree<number, string>();
|
|
3708
|
-
tree.setMany([
|
|
3650
|
+
tree.setMany([
|
|
3651
|
+
[1, 'a'],
|
|
3652
|
+
[2, 'b'],
|
|
3653
|
+
[3, 'c']
|
|
3654
|
+
]);
|
|
3709
3655
|
console.log(tree.size); // 3;
|
|
3710
3656
|
```
|
|
3711
3657
|
|
|
@@ -3789,7 +3735,7 @@ Time O(n), Space O(n)
|
|
|
3789
3735
|
toVisual(startNode?, options?): string;
|
|
3790
3736
|
```
|
|
3791
3737
|
|
|
3792
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
3738
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:2004](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L2004)
|
|
3793
3739
|
|
|
3794
3740
|
Generates a string representation of the tree for visualization.
|
|
3795
3741
|
|
|
@@ -3867,7 +3813,7 @@ IBinaryTree.values
|
|
|
3867
3813
|
protected readonly _DEFAULT_NODE_CALLBACK: NodeCallback<BinaryTreeNode<K, V> | null | undefined, K | undefined>;
|
|
3868
3814
|
```
|
|
3869
3815
|
|
|
3870
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
3816
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:2298](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L2298)
|
|
3871
3817
|
|
|
3872
3818
|
(Protected) Default callback function, returns the node's key.
|
|
3873
3819
|
|
|
@@ -3891,7 +3837,7 @@ The node's key or undefined.
|
|
|
3891
3837
|
protected _clearNodes(): void;
|
|
3892
3838
|
```
|
|
3893
3839
|
|
|
3894
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
3840
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:2701](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L2701)
|
|
3895
3841
|
|
|
3896
3842
|
(Protected) Clears all nodes from the tree.
|
|
3897
3843
|
|
|
@@ -3911,7 +3857,7 @@ Time O(1)
|
|
|
3911
3857
|
protected _clearValues(): void;
|
|
3912
3858
|
```
|
|
3913
3859
|
|
|
3914
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
3860
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:2710](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L2710)
|
|
3915
3861
|
|
|
3916
3862
|
(Protected) Clears all values from the external store.
|
|
3917
3863
|
|
|
@@ -3931,7 +3877,7 @@ Time O(N)
|
|
|
3931
3877
|
protected _clone(cloned): void;
|
|
3932
3878
|
```
|
|
3933
3879
|
|
|
3934
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
3880
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:2392](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L2392)
|
|
3935
3881
|
|
|
3936
3882
|
(Protected) Helper for cloning. Performs a BFS and sets all nodes to the new tree.
|
|
3937
3883
|
|
|
@@ -3959,7 +3905,7 @@ Time O(N * M) (O(N) BFS + O(M) `set` for each node).
|
|
|
3959
3905
|
protected _createInstance<TK, TV, TR>(options?): this;
|
|
3960
3906
|
```
|
|
3961
3907
|
|
|
3962
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
3908
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:2326](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L2326)
|
|
3963
3909
|
|
|
3964
3910
|
(Protected) Creates a new, empty instance of the same tree constructor.
|
|
3965
3911
|
|
|
@@ -4003,7 +3949,7 @@ Time O(1)
|
|
|
4003
3949
|
protected _createLike<TK, TV, TR>(iter?, options?): BinaryTree<TK, TV, TR>;
|
|
4004
3950
|
```
|
|
4005
3951
|
|
|
4006
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
3952
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:2343](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L2343)
|
|
4007
3953
|
|
|
4008
3954
|
(Protected) Creates a new instance of the same tree constructor, potentially with different generic types.
|
|
4009
3955
|
|
|
@@ -4059,7 +4005,7 @@ Time O(N) (or as per constructor) due to processing the iterable.
|
|
|
4059
4005
|
protected _deleteInternal(keyNodeEntryRawOrPredicate): BinaryTreeDeleteResult<BinaryTreeNode<K, V>>[];
|
|
4060
4006
|
```
|
|
4061
4007
|
|
|
4062
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
4008
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:2056](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L2056)
|
|
4063
4009
|
|
|
4064
4010
|
**`Internal`**
|
|
4065
4011
|
|
|
@@ -4103,7 +4049,7 @@ protected _dfs<C>(
|
|
|
4103
4049
|
shouldProcessRoot?): ReturnType<C>[];
|
|
4104
4050
|
```
|
|
4105
4051
|
|
|
4106
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
4052
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:2109](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L2109)
|
|
4107
4053
|
|
|
4108
4054
|
#### Type Parameters
|
|
4109
4055
|
|
|
@@ -4192,7 +4138,7 @@ Array of callback results.
|
|
|
4192
4138
|
protected _displayAux(node, options): NodeDisplayLayout;
|
|
4193
4139
|
```
|
|
4194
4140
|
|
|
4195
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
4141
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:2416](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L2416)
|
|
4196
4142
|
|
|
4197
4143
|
(Protected) Recursive helper for `toVisual`.
|
|
4198
4144
|
|
|
@@ -4228,7 +4174,7 @@ Time O(N), Space O(N*H) or O(N^2)
|
|
|
4228
4174
|
protected _ensurePredicate(keyNodeEntryOrPredicate): NodePredicate<BinaryTreeNode<K, V>>;
|
|
4229
4175
|
```
|
|
4230
4176
|
|
|
4231
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
4177
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:2607](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L2607)
|
|
4232
4178
|
|
|
4233
4179
|
(Protected) Converts a key, node, entry, or predicate into a standardized predicate function.
|
|
4234
4180
|
|
|
@@ -4263,7 +4209,7 @@ Time O(1)
|
|
|
4263
4209
|
protected _extractKey(keyNodeOrEntry): K | null | undefined;
|
|
4264
4210
|
```
|
|
4265
4211
|
|
|
4266
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
4212
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:2667](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L2667)
|
|
4267
4213
|
|
|
4268
4214
|
(Protected) Extracts the key from a key, node, or entry.
|
|
4269
4215
|
|
|
@@ -4297,7 +4243,7 @@ Time O(1)
|
|
|
4297
4243
|
protected _getIterator(node?): IterableIterator<[K, V | undefined]>;
|
|
4298
4244
|
```
|
|
4299
4245
|
|
|
4300
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
4246
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:2254](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L2254)
|
|
4301
4247
|
|
|
4302
4248
|
(Protected) Gets the iterator for the tree (default in-order).
|
|
4303
4249
|
|
|
@@ -4331,7 +4277,7 @@ Time O(N) for full iteration. O(H) to get the first element. Space O(H) for the
|
|
|
4331
4277
|
protected _isDisplayLeaf(node, options): boolean;
|
|
4332
4278
|
```
|
|
4333
4279
|
|
|
4334
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
4280
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:2482](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L2482)
|
|
4335
4281
|
|
|
4336
4282
|
Check if a node is a display leaf (empty, null, undefined, NIL, or real leaf).
|
|
4337
4283
|
|
|
@@ -4357,7 +4303,7 @@ Check if a node is a display leaf (empty, null, undefined, NIL, or real leaf).
|
|
|
4357
4303
|
protected _isPredicate(p): p is NodePredicate<BinaryTreeNode<K, V>>;
|
|
4358
4304
|
```
|
|
4359
4305
|
|
|
4360
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
4306
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:2656](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L2656)
|
|
4361
4307
|
|
|
4362
4308
|
(Protected) Checks if an item is a predicate function.
|
|
4363
4309
|
|
|
@@ -4387,7 +4333,7 @@ Time O(1)
|
|
|
4387
4333
|
protected _keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry, value?): [BinaryTreeNode<K, V> | null | undefined, V | undefined];
|
|
4388
4334
|
```
|
|
4389
4335
|
|
|
4390
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
4336
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:2366](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L2366)
|
|
4391
4337
|
|
|
4392
4338
|
(Protected) Converts a key, node, or entry into a standardized [node, value] tuple.
|
|
4393
4339
|
|
|
@@ -4427,7 +4373,7 @@ Time O(1)
|
|
|
4427
4373
|
protected _replaceNode(oldNode, newNode): BinaryTreeNode<K, V>;
|
|
4428
4374
|
```
|
|
4429
4375
|
|
|
4430
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
4376
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:2569](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L2569)
|
|
4431
4377
|
|
|
4432
4378
|
(Protected) Replaces a node in the tree with a new node, maintaining children and parent links.
|
|
4433
4379
|
|
|
@@ -4466,7 +4412,7 @@ protected _resolveDisplayLeaf(
|
|
|
4466
4412
|
emptyDisplayLayout): NodeDisplayLayout;
|
|
4467
4413
|
```
|
|
4468
4414
|
|
|
4469
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
4415
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:2509](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L2509)
|
|
4470
4416
|
|
|
4471
4417
|
Resolve a display leaf node to its layout.
|
|
4472
4418
|
|
|
@@ -4496,7 +4442,7 @@ Resolve a display leaf node to its layout.
|
|
|
4496
4442
|
protected _setRoot(v): void;
|
|
4497
4443
|
```
|
|
4498
4444
|
|
|
4499
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
4445
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:2593](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L2593)
|
|
4500
4446
|
|
|
4501
4447
|
(Protected) Sets the root node and clears its parent reference.
|
|
4502
4448
|
|
|
@@ -4524,7 +4470,7 @@ Time O(1)
|
|
|
4524
4470
|
protected _setValue(key, value): boolean;
|
|
4525
4471
|
```
|
|
4526
4472
|
|
|
4527
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
4473
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:2688](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L2688)
|
|
4528
4474
|
|
|
4529
4475
|
(Protected) Sets a value in the external store (Map mode).
|
|
4530
4476
|
|
|
@@ -4560,7 +4506,7 @@ Time O(1) (average for Map.set).
|
|
|
4560
4506
|
protected _snapshotOptions<TK, TV, TR>(): BinaryTreeOptions<TK, TV, TR>;
|
|
4561
4507
|
```
|
|
4562
4508
|
|
|
4563
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
4509
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:2309](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L2309)
|
|
4564
4510
|
|
|
4565
4511
|
(Protected) Snapshots the current tree's configuration options.
|
|
4566
4512
|
|
|
@@ -4596,7 +4542,7 @@ Time O(1)
|
|
|
4596
4542
|
protected _swapProperties(srcNode, destNode): BinaryTreeNode<K, V> | undefined;
|
|
4597
4543
|
```
|
|
4598
4544
|
|
|
4599
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
4545
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:2535](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L2535)
|
|
4600
4546
|
|
|
4601
4547
|
(Protected) Swaps the key/value properties of two nodes.
|
|
4602
4548
|
|