data-structure-typed 1.32.1 → 1.32.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 +1 -1
- package/README.md +57 -187
- package/coverage/clover.xml +33 -33
- package/coverage/coverage-final.json +2 -2
- package/coverage/lcov-report/index.html +1 -1
- package/coverage/lcov-report/src/data-structures/binary-tree/aa-tree.ts.html +1 -1
- package/coverage/lcov-report/src/data-structures/binary-tree/abstract-binary-tree.ts.html +1 -1
- package/coverage/lcov-report/src/data-structures/binary-tree/avl-tree.ts.html +1 -1
- package/coverage/lcov-report/src/data-structures/binary-tree/b-tree.ts.html +1 -1
- package/coverage/lcov-report/src/data-structures/binary-tree/binary-indexed-tree.ts.html +1 -1
- package/coverage/lcov-report/src/data-structures/binary-tree/binary-tree.ts.html +1 -1
- package/coverage/lcov-report/src/data-structures/binary-tree/bst.ts.html +1 -1
- package/coverage/lcov-report/src/data-structures/binary-tree/index.html +1 -1
- package/coverage/lcov-report/src/data-structures/binary-tree/index.ts.html +1 -1
- package/coverage/lcov-report/src/data-structures/binary-tree/rb-tree.ts.html +1 -1
- package/coverage/lcov-report/src/data-structures/binary-tree/segment-tree.ts.html +1 -1
- package/coverage/lcov-report/src/data-structures/binary-tree/splay-tree.ts.html +1 -1
- package/coverage/lcov-report/src/data-structures/binary-tree/tree-multiset.ts.html +1 -1
- package/coverage/lcov-report/src/data-structures/binary-tree/two-three-tree.ts.html +1 -1
- package/coverage/lcov-report/src/data-structures/graph/abstract-graph.ts.html +1 -1
- package/coverage/lcov-report/src/data-structures/graph/directed-graph.ts.html +1 -1
- package/coverage/lcov-report/src/data-structures/graph/index.html +1 -1
- package/coverage/lcov-report/src/data-structures/graph/index.ts.html +1 -1
- package/coverage/lcov-report/src/data-structures/graph/map-graph.ts.html +1 -1
- package/coverage/lcov-report/src/data-structures/graph/undirected-graph.ts.html +1 -1
- package/coverage/lcov-report/src/data-structures/hash/coordinate-map.ts.html +1 -1
- package/coverage/lcov-report/src/data-structures/hash/coordinate-set.ts.html +1 -1
- package/coverage/lcov-report/src/data-structures/hash/hash-table.ts.html +1 -1
- package/coverage/lcov-report/src/data-structures/hash/index.html +1 -1
- package/coverage/lcov-report/src/data-structures/hash/index.ts.html +1 -1
- package/coverage/lcov-report/src/data-structures/hash/pair.ts.html +1 -1
- package/coverage/lcov-report/src/data-structures/hash/tree-map.ts.html +1 -1
- package/coverage/lcov-report/src/data-structures/hash/tree-set.ts.html +1 -1
- package/coverage/lcov-report/src/data-structures/heap/heap.ts.html +1 -1
- package/coverage/lcov-report/src/data-structures/heap/index.html +1 -1
- package/coverage/lcov-report/src/data-structures/heap/index.ts.html +1 -1
- package/coverage/lcov-report/src/data-structures/heap/max-heap.ts.html +1 -1
- package/coverage/lcov-report/src/data-structures/heap/min-heap.ts.html +1 -1
- package/coverage/lcov-report/src/data-structures/index.html +1 -1
- package/coverage/lcov-report/src/data-structures/index.ts.html +1 -1
- package/coverage/lcov-report/src/data-structures/linked-list/doubly-linked-list.ts.html +1 -1
- package/coverage/lcov-report/src/data-structures/linked-list/index.html +1 -1
- package/coverage/lcov-report/src/data-structures/linked-list/index.ts.html +1 -1
- package/coverage/lcov-report/src/data-structures/linked-list/singly-linked-list.ts.html +1 -1
- package/coverage/lcov-report/src/data-structures/linked-list/skip-linked-list.ts.html +1 -1
- package/coverage/lcov-report/src/data-structures/matrix/index.html +1 -1
- package/coverage/lcov-report/src/data-structures/matrix/index.ts.html +1 -1
- package/coverage/lcov-report/src/data-structures/matrix/matrix.ts.html +1 -1
- package/coverage/lcov-report/src/data-structures/matrix/matrix2d.ts.html +1 -1
- package/coverage/lcov-report/src/data-structures/matrix/navigator.ts.html +1 -1
- package/coverage/lcov-report/src/data-structures/matrix/vector2d.ts.html +1 -1
- package/coverage/lcov-report/src/data-structures/priority-queue/index.html +1 -1
- package/coverage/lcov-report/src/data-structures/priority-queue/index.ts.html +1 -1
- package/coverage/lcov-report/src/data-structures/priority-queue/max-priority-queue.ts.html +4 -4
- package/coverage/lcov-report/src/data-structures/priority-queue/min-priority-queue.ts.html +1 -1
- package/coverage/lcov-report/src/data-structures/priority-queue/priority-queue.ts.html +29 -29
- package/coverage/lcov-report/src/data-structures/queue/deque.ts.html +1 -1
- package/coverage/lcov-report/src/data-structures/queue/index.html +1 -1
- package/coverage/lcov-report/src/data-structures/queue/index.ts.html +1 -1
- package/coverage/lcov-report/src/data-structures/queue/queue.ts.html +1 -1
- package/coverage/lcov-report/src/data-structures/stack/index.html +1 -1
- package/coverage/lcov-report/src/data-structures/stack/index.ts.html +1 -1
- package/coverage/lcov-report/src/data-structures/stack/stack.ts.html +1 -1
- package/coverage/lcov-report/src/data-structures/tree/index.html +1 -1
- package/coverage/lcov-report/src/data-structures/tree/index.ts.html +1 -1
- package/coverage/lcov-report/src/data-structures/tree/tree.ts.html +1 -1
- package/coverage/lcov-report/src/data-structures/trie/index.html +1 -1
- package/coverage/lcov-report/src/data-structures/trie/index.ts.html +1 -1
- package/coverage/lcov-report/src/data-structures/trie/trie.ts.html +1 -1
- package/coverage/lcov-report/src/index.html +1 -1
- package/coverage/lcov-report/src/index.ts.html +1 -1
- package/coverage/lcov-report/src/interfaces/index.html +1 -1
- package/coverage/lcov-report/src/interfaces/index.ts.html +1 -1
- package/coverage/lcov-report/src/types/data-structures/abstract-binary-tree.ts.html +1 -1
- package/coverage/lcov-report/src/types/data-structures/bst.ts.html +1 -1
- package/coverage/lcov-report/src/types/data-structures/directed-graph.ts.html +1 -1
- package/coverage/lcov-report/src/types/data-structures/index.html +1 -1
- package/coverage/lcov-report/src/types/data-structures/index.ts.html +1 -1
- package/coverage/lcov-report/src/types/data-structures/rb-tree.ts.html +1 -1
- package/coverage/lcov-report/src/types/index.html +1 -1
- package/coverage/lcov-report/src/types/index.ts.html +1 -1
- package/coverage/lcov-report/src/types/utils/index.html +1 -1
- package/coverage/lcov-report/src/types/utils/index.ts.html +1 -1
- package/coverage/lcov-report/src/utils/index.html +1 -1
- package/coverage/lcov-report/src/utils/index.ts.html +1 -1
- package/coverage/lcov-report/src/utils/utils.ts.html +1 -1
- package/coverage/lcov-report/test/utils/index.html +1 -1
- package/coverage/lcov-report/test/utils/index.ts.html +1 -1
- package/coverage/lcov-report/test/utils/magnitude.ts.html +1 -1
- package/coverage/lcov-report/test/utils/number.ts.html +1 -1
- package/coverage/lcov.info +51 -51
- package/docs/classes/AVLTree.html +85 -85
- package/docs/classes/AVLTreeNode.html +15 -15
- package/docs/classes/AaTree.html +1 -1
- package/docs/classes/AbstractBinaryTree.html +78 -78
- package/docs/classes/AbstractBinaryTreeNode.html +21 -21
- package/docs/classes/AbstractEdge.html +11 -11
- package/docs/classes/AbstractGraph.html +36 -36
- package/docs/classes/AbstractVertex.html +8 -8
- package/docs/classes/ArrayDeque.html +14 -14
- package/docs/classes/BST.html +78 -78
- package/docs/classes/BSTNode.html +15 -15
- package/docs/classes/BTree.html +1 -1
- package/docs/classes/BinaryIndexedTree.html +9 -9
- package/docs/classes/BinaryTree.html +71 -71
- package/docs/classes/BinaryTreeNode.html +15 -15
- package/docs/classes/Character.html +4 -4
- package/docs/classes/CoordinateMap.html +9 -9
- package/docs/classes/CoordinateSet.html +8 -8
- package/docs/classes/Deque.html +34 -34
- package/docs/classes/DirectedEdge.html +15 -15
- package/docs/classes/DirectedGraph.html +52 -52
- package/docs/classes/DirectedVertex.html +6 -6
- package/docs/classes/DoublyLinkedList.html +37 -37
- package/docs/classes/DoublyLinkedListNode.html +11 -11
- package/docs/classes/HashTable.html +1 -1
- package/docs/classes/Heap.html +26 -26
- package/docs/classes/HeapItem.html +8 -8
- package/docs/classes/LinkedListQueue.html +35 -35
- package/docs/classes/MapEdge.html +13 -13
- package/docs/classes/MapGraph.html +56 -56
- package/docs/classes/MapVertex.html +12 -12
- package/docs/classes/Matrix2D.html +16 -16
- package/docs/classes/MatrixNTI2D.html +4 -4
- package/docs/classes/MaxHeap.html +26 -26
- package/docs/classes/MaxPriorityQueue.html +34 -34
- package/docs/classes/MinHeap.html +26 -26
- package/docs/classes/MinPriorityQueue.html +34 -34
- package/docs/classes/Navigator.html +10 -10
- package/docs/classes/ObjectDeque.html +25 -25
- package/docs/classes/Pair.html +1 -1
- package/docs/classes/PriorityQueue.html +32 -32
- package/docs/classes/Queue.html +22 -22
- package/docs/classes/RBTree.html +78 -78
- package/docs/classes/RBTreeNode.html +18 -18
- package/docs/classes/SegmentTree.html +17 -17
- package/docs/classes/SegmentTreeNode.html +20 -20
- package/docs/classes/SinglyLinkedList.html +35 -35
- package/docs/classes/SinglyLinkedListNode.html +8 -8
- package/docs/classes/SkipLinkedList.html +1 -1
- package/docs/classes/SplayTree.html +1 -1
- package/docs/classes/Stack.html +12 -12
- package/docs/classes/TreeMap.html +1 -1
- package/docs/classes/TreeMultiset.html +99 -99
- package/docs/classes/TreeMultisetNode.html +18 -18
- package/docs/classes/TreeNode.html +13 -13
- package/docs/classes/TreeSet.html +1 -1
- package/docs/classes/Trie.html +13 -13
- package/docs/classes/TrieNode.html +11 -11
- package/docs/classes/TwoThreeTree.html +1 -1
- package/docs/classes/UndirectedEdge.html +12 -12
- package/docs/classes/UndirectedGraph.html +40 -40
- package/docs/classes/UndirectedVertex.html +6 -6
- package/docs/classes/Vector2D.html +28 -28
- package/docs/enums/CP.html +4 -4
- package/docs/enums/FamilyPosition.html +8 -8
- package/docs/enums/LoopType.html +3 -3
- package/docs/enums/RBColor.html +3 -3
- package/docs/enums/TopologicalProperty.html +4 -4
- package/docs/functions/arrayRemove.html +1 -1
- package/docs/functions/isThunk.html +1 -1
- package/docs/functions/toThunk.html +1 -1
- package/docs/functions/trampoline.html +1 -1
- package/docs/functions/trampolineAsync.html +1 -1
- package/docs/functions/uuidV4.html +1 -1
- package/docs/index.html +13 -17
- package/docs/interfaces/IAVLTree.html +77 -77
- package/docs/interfaces/IAbstractBinaryTree.html +72 -72
- package/docs/interfaces/IAbstractBinaryTreeNode.html +14 -14
- package/docs/interfaces/IAbstractGraph.html +15 -15
- package/docs/interfaces/IBST.html +77 -77
- package/docs/interfaces/IDirectedGraph.html +23 -23
- package/docs/interfaces/IRBTree.html +77 -77
- package/docs/interfaces/IUNDirectedGraph.html +16 -16
- package/docs/types/AVLTreeNodeNested.html +1 -1
- package/docs/types/AVLTreeOptions.html +1 -1
- package/docs/types/AbstractBinaryTreeNodeNested.html +1 -1
- package/docs/types/AbstractBinaryTreeNodeProperties.html +1 -1
- package/docs/types/AbstractBinaryTreeNodeProperty.html +1 -1
- package/docs/types/AbstractBinaryTreeOptions.html +1 -1
- package/docs/types/BSTComparator.html +1 -1
- package/docs/types/BSTNodeNested.html +1 -1
- package/docs/types/BSTOptions.html +1 -1
- package/docs/types/BinaryTreeDeletedResult.html +1 -1
- package/docs/types/BinaryTreeNodeId.html +1 -1
- package/docs/types/BinaryTreeNodeNested.html +1 -1
- package/docs/types/BinaryTreeNodePropertyName.html +1 -1
- package/docs/types/BinaryTreeOptions.html +1 -1
- package/docs/types/DFSOrderPattern.html +1 -1
- package/docs/types/DijkstraResult.html +1 -1
- package/docs/types/Direction.html +1 -1
- package/docs/types/DummyAny.html +1 -1
- package/docs/types/EdgeId.html +1 -1
- package/docs/types/HeapOptions.html +1 -1
- package/docs/types/IAVLTreeNode.html +1 -1
- package/docs/types/IBSTNode.html +1 -1
- package/docs/types/IBinaryTree.html +1 -1
- package/docs/types/IBinaryTreeNode.html +1 -1
- package/docs/types/IRBTreeNode.html +1 -1
- package/docs/types/ITreeMultiset.html +1 -1
- package/docs/types/ITreeMultisetNode.html +1 -1
- package/docs/types/KeyValueObject.html +1 -1
- package/docs/types/KeyValueObjectWithId.html +1 -1
- package/docs/types/MapGraphCoordinate.html +1 -1
- package/docs/types/NavigatorParams.html +1 -1
- package/docs/types/NodeOrPropertyName.html +1 -1
- package/docs/types/NonNumberNonObjectButDefined.html +1 -1
- package/docs/types/ObjectWithNonNumberId.html +1 -1
- package/docs/types/ObjectWithNumberId.html +1 -1
- package/docs/types/ObjectWithoutId.html +1 -1
- package/docs/types/PriorityQueueComparator.html +1 -1
- package/docs/types/PriorityQueueDFSOrderPattern.html +1 -1
- package/docs/types/PriorityQueueOptions.html +1 -1
- package/docs/types/RBTreeNodeNested.html +1 -1
- package/docs/types/RBTreeOptions.html +1 -1
- package/docs/types/RestrictValById.html +1 -1
- package/docs/types/SegmentTreeNodeVal.html +1 -1
- package/docs/types/SpecifyOptional.html +1 -1
- package/docs/types/Thunk.html +1 -1
- package/docs/types/ToThunkFn.html +1 -1
- package/docs/types/TopologicalStatus.html +1 -1
- package/docs/types/TreeMultisetNodeNested.html +1 -1
- package/docs/types/TreeMultisetOptions.html +1 -1
- package/docs/types/TrlAsyncFn.html +1 -1
- package/docs/types/TrlFn.html +1 -1
- package/docs/types/Turning.html +1 -1
- package/docs/types/VertexId.html +1 -1
- package/docs/variables/THUNK_SYMBOL.html +1 -1
- package/package.json +1 -1
- package/.auto-changelog-template.hbs +0 -36
- package/rename_clear_files.sh +0 -29
- package/src/data-structures/binary-tree/aa-tree.ts +0 -1
- package/src/data-structures/binary-tree/abstract-binary-tree.ts +0 -1631
- package/src/data-structures/binary-tree/avl-tree.ts +0 -310
- package/src/data-structures/binary-tree/b-tree.ts +0 -1
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +0 -76
- package/src/data-structures/binary-tree/binary-tree.ts +0 -47
- package/src/data-structures/binary-tree/bst.ts +0 -537
- package/src/data-structures/binary-tree/index.ts +0 -12
- package/src/data-structures/binary-tree/rb-tree.ts +0 -101
- package/src/data-structures/binary-tree/segment-tree.ts +0 -242
- package/src/data-structures/binary-tree/splay-tree.ts +0 -1
- package/src/data-structures/binary-tree/tree-multiset.ts +0 -700
- package/src/data-structures/binary-tree/two-three-tree.ts +0 -1
- package/src/data-structures/diagrams/README.md +0 -5
- package/src/data-structures/graph/abstract-graph.ts +0 -1040
- package/src/data-structures/graph/directed-graph.ts +0 -470
- package/src/data-structures/graph/index.ts +0 -4
- package/src/data-structures/graph/map-graph.ts +0 -129
- package/src/data-structures/graph/undirected-graph.ts +0 -274
- package/src/data-structures/hash/coordinate-map.ts +0 -67
- package/src/data-structures/hash/coordinate-set.ts +0 -56
- package/src/data-structures/hash/hash-table.ts +0 -1
- package/src/data-structures/hash/index.ts +0 -6
- package/src/data-structures/hash/pair.ts +0 -1
- package/src/data-structures/hash/tree-map.ts +0 -1
- package/src/data-structures/hash/tree-set.ts +0 -1
- package/src/data-structures/heap/heap.ts +0 -212
- package/src/data-structures/heap/index.ts +0 -3
- package/src/data-structures/heap/max-heap.ts +0 -31
- package/src/data-structures/heap/min-heap.ts +0 -32
- package/src/data-structures/index.ts +0 -11
- package/src/data-structures/linked-list/doubly-linked-list.ts +0 -573
- package/src/data-structures/linked-list/index.ts +0 -3
- package/src/data-structures/linked-list/singly-linked-list.ts +0 -501
- package/src/data-structures/linked-list/skip-linked-list.ts +0 -1
- package/src/data-structures/matrix/index.ts +0 -4
- package/src/data-structures/matrix/matrix.ts +0 -27
- package/src/data-structures/matrix/matrix2d.ts +0 -212
- package/src/data-structures/matrix/navigator.ts +0 -121
- package/src/data-structures/matrix/vector2d.ts +0 -316
- package/src/data-structures/priority-queue/index.ts +0 -3
- package/src/data-structures/priority-queue/max-priority-queue.ts +0 -56
- package/src/data-structures/priority-queue/min-priority-queue.ts +0 -57
- package/src/data-structures/priority-queue/priority-queue.ts +0 -359
- package/src/data-structures/queue/deque.ts +0 -297
- package/src/data-structures/queue/index.ts +0 -2
- package/src/data-structures/queue/queue.ts +0 -191
- package/src/data-structures/stack/index.ts +0 -1
- package/src/data-structures/stack/stack.ts +0 -98
- package/src/data-structures/tree/index.ts +0 -1
- package/src/data-structures/tree/tree.ts +0 -69
- package/src/data-structures/trie/index.ts +0 -1
- package/src/data-structures/trie/trie.ts +0 -225
- package/src/index.ts +0 -4
- package/src/interfaces/abstract-binary-tree.ts +0 -191
- package/src/interfaces/abstract-graph.ts +0 -31
- package/src/interfaces/avl-tree.ts +0 -25
- package/src/interfaces/binary-tree.ts +0 -6
- package/src/interfaces/bst.ts +0 -31
- package/src/interfaces/directed-graph.ts +0 -20
- package/src/interfaces/doubly-linked-list.ts +0 -1
- package/src/interfaces/heap.ts +0 -1
- package/src/interfaces/index.ts +0 -15
- package/src/interfaces/navigator.ts +0 -1
- package/src/interfaces/priority-queue.ts +0 -1
- package/src/interfaces/rb-tree.ts +0 -9
- package/src/interfaces/segment-tree.ts +0 -1
- package/src/interfaces/singly-linked-list.ts +0 -1
- package/src/interfaces/tree-multiset.ts +0 -7
- package/src/interfaces/undirected-graph.ts +0 -6
- package/src/types/data-structures/abstract-binary-tree.ts +0 -50
- package/src/types/data-structures/abstract-graph.ts +0 -11
- package/src/types/data-structures/avl-tree.ts +0 -5
- package/src/types/data-structures/binary-tree.ts +0 -5
- package/src/types/data-structures/bst.ts +0 -13
- package/src/types/data-structures/directed-graph.ts +0 -8
- package/src/types/data-structures/doubly-linked-list.ts +0 -1
- package/src/types/data-structures/heap.ts +0 -5
- package/src/types/data-structures/index.ts +0 -15
- package/src/types/data-structures/map-graph.ts +0 -1
- package/src/types/data-structures/navigator.ts +0 -13
- package/src/types/data-structures/priority-queue.ts +0 -9
- package/src/types/data-structures/rb-tree.ts +0 -8
- package/src/types/data-structures/segment-tree.ts +0 -1
- package/src/types/data-structures/singly-linked-list.ts +0 -1
- package/src/types/data-structures/tree-multiset.ts +0 -6
- package/src/types/helpers.ts +0 -1
- package/src/types/index.ts +0 -3
- package/src/types/utils/index.ts +0 -2
- package/src/types/utils/utils.ts +0 -6
- package/src/types/utils/validate-type.ts +0 -35
- package/src/utils/index.ts +0 -1
- package/src/utils/utils.ts +0 -79
- package/tsconfig.build.json +0 -33
|
@@ -1,225 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* data-structure-typed
|
|
3
|
-
*
|
|
4
|
-
* @author Tyler Zeng
|
|
5
|
-
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
|
|
6
|
-
* @license MIT License
|
|
7
|
-
*/
|
|
8
|
-
export class TrieNode {
|
|
9
|
-
constructor(v: string) {
|
|
10
|
-
this._val = v;
|
|
11
|
-
this._isEnd = false;
|
|
12
|
-
this._children = new Map<string, TrieNode>();
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
private _val;
|
|
16
|
-
|
|
17
|
-
get val(): string {
|
|
18
|
-
return this._val;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
set val(v: string) {
|
|
22
|
-
this._val = v;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
protected _children: Map<string, TrieNode>;
|
|
26
|
-
|
|
27
|
-
get children(): Map<string, TrieNode> {
|
|
28
|
-
return this._children;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
set children(v: Map<string, TrieNode>) {
|
|
32
|
-
this._children = v;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
protected _isEnd: boolean;
|
|
36
|
-
|
|
37
|
-
get isEnd(): boolean {
|
|
38
|
-
return this._isEnd;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
set isEnd(v: boolean) {
|
|
42
|
-
this._isEnd = v;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export class Trie {
|
|
47
|
-
constructor(words?: string[]) {
|
|
48
|
-
this._root = new TrieNode('');
|
|
49
|
-
if (words) {
|
|
50
|
-
for (const i of words) {
|
|
51
|
-
this.add(i);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
protected _root: TrieNode;
|
|
57
|
-
|
|
58
|
-
get root() {
|
|
59
|
-
return this._root;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
set root(v: TrieNode) {
|
|
63
|
-
this._root = v;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
add(word: string): boolean {
|
|
67
|
-
let cur = this._root;
|
|
68
|
-
for (const c of word) {
|
|
69
|
-
let nodeC = cur.children.get(c);
|
|
70
|
-
if (!nodeC) {
|
|
71
|
-
nodeC = new TrieNode(c);
|
|
72
|
-
cur.children.set(c, nodeC);
|
|
73
|
-
}
|
|
74
|
-
cur = nodeC;
|
|
75
|
-
}
|
|
76
|
-
cur.isEnd = true;
|
|
77
|
-
return true;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
has(input: string): boolean {
|
|
81
|
-
let cur = this._root;
|
|
82
|
-
for (const c of input) {
|
|
83
|
-
const nodeC = cur.children.get(c);
|
|
84
|
-
if (!nodeC) return false;
|
|
85
|
-
cur = nodeC;
|
|
86
|
-
}
|
|
87
|
-
return cur.isEnd;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
remove(word: string) {
|
|
91
|
-
let isDeleted = false;
|
|
92
|
-
const dfs = (cur: TrieNode, i: number): boolean => {
|
|
93
|
-
const char = word[i];
|
|
94
|
-
const child = cur.children.get(char);
|
|
95
|
-
if (child) {
|
|
96
|
-
if (i === word.length - 1) {
|
|
97
|
-
if (child.isEnd) {
|
|
98
|
-
if (child.children.size > 0) {
|
|
99
|
-
child.isEnd = false;
|
|
100
|
-
} else {
|
|
101
|
-
cur.children.delete(char);
|
|
102
|
-
}
|
|
103
|
-
isDeleted = true;
|
|
104
|
-
return true;
|
|
105
|
-
}
|
|
106
|
-
return false;
|
|
107
|
-
}
|
|
108
|
-
const res = dfs(child, i + 1);
|
|
109
|
-
if (res && !cur.isEnd && child.children.size === 0) {
|
|
110
|
-
cur.children.delete(char);
|
|
111
|
-
return true;
|
|
112
|
-
}
|
|
113
|
-
return false;
|
|
114
|
-
}
|
|
115
|
-
return false;
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
dfs(this.root, 0);
|
|
119
|
-
return isDeleted;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// --- start additional methods ---
|
|
123
|
-
/**
|
|
124
|
-
* The function checks if a given input string has an absolute prefix in a tree data structure.Only can present as a prefix, not a word
|
|
125
|
-
* @param {string} input - The input parameter is a string that represents the input value for the function.
|
|
126
|
-
* @returns a boolean value.
|
|
127
|
-
*/
|
|
128
|
-
isAbsPrefix(input: string): boolean {
|
|
129
|
-
let cur = this._root;
|
|
130
|
-
for (const c of input) {
|
|
131
|
-
const nodeC = cur.children.get(c);
|
|
132
|
-
if (!nodeC) return false;
|
|
133
|
-
cur = nodeC;
|
|
134
|
-
}
|
|
135
|
-
return !cur.isEnd;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* The function checks if a given input string is a prefix of any existing string in a tree structure.Can present as a abs prefix or word
|
|
140
|
-
* @param {string} input - The input parameter is a string that represents the prefix we want to check.
|
|
141
|
-
* @returns a boolean value.
|
|
142
|
-
*/
|
|
143
|
-
isPrefix(input: string): boolean {
|
|
144
|
-
let cur = this._root;
|
|
145
|
-
for (const c of input) {
|
|
146
|
-
const nodeC = cur.children.get(c);
|
|
147
|
-
if (!nodeC) return false;
|
|
148
|
-
cur = nodeC;
|
|
149
|
-
}
|
|
150
|
-
return true;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* The function checks if the input string is a common prefix in a Trie data structure.Check if the input string is the common prefix of all the words
|
|
155
|
-
* @param {string} input - The input parameter is a string that represents the common prefix that we want to check for
|
|
156
|
-
* in the Trie data structure.
|
|
157
|
-
* @returns a boolean value indicating whether the input string is a common prefix in the Trie data structure.
|
|
158
|
-
*/
|
|
159
|
-
isCommonPrefix(input: string): boolean {
|
|
160
|
-
let commonPre = '';
|
|
161
|
-
const dfs = (cur: TrieNode) => {
|
|
162
|
-
commonPre += cur.val;
|
|
163
|
-
if (commonPre === input) return;
|
|
164
|
-
if (cur.isEnd) return;
|
|
165
|
-
if (cur && cur.children && cur.children.size === 1) dfs(Array.from(cur.children.values())[0]);
|
|
166
|
-
else return;
|
|
167
|
-
};
|
|
168
|
-
dfs(this._root);
|
|
169
|
-
return commonPre === input;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
/**
|
|
173
|
-
* The function `getLongestCommonPrefix` returns the longest common prefix among all the words stored in a Trie data
|
|
174
|
-
* structure.
|
|
175
|
-
* @returns The function `getLongestCommonPrefix` returns a string, which is the longest common prefix found in the
|
|
176
|
-
* Trie.
|
|
177
|
-
*/
|
|
178
|
-
getLongestCommonPrefix(): string {
|
|
179
|
-
let commonPre = '';
|
|
180
|
-
const dfs = (cur: TrieNode) => {
|
|
181
|
-
commonPre += cur.val;
|
|
182
|
-
if (cur.isEnd) return;
|
|
183
|
-
if (cur && cur.children && cur.children.size === 1) dfs(Array.from(cur.children.values())[0]);
|
|
184
|
-
else return;
|
|
185
|
-
};
|
|
186
|
-
dfs(this._root);
|
|
187
|
-
return commonPre;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
/**
|
|
191
|
-
* The `getAll` function returns an array of all words in a Trie data structure that start with a given prefix.
|
|
192
|
-
* @param [prefix] - The `prefix` parameter is a string that represents the prefix that we want to search for in the
|
|
193
|
-
* trie. It is an optional parameter, so if no prefix is provided, it will default to an empty string.
|
|
194
|
-
* @returns an array of strings.
|
|
195
|
-
*/
|
|
196
|
-
getAll(prefix = ''): string[] {
|
|
197
|
-
const words: string[] = [];
|
|
198
|
-
|
|
199
|
-
function dfs(node: TrieNode, word: string) {
|
|
200
|
-
for (const char of node.children.keys()) {
|
|
201
|
-
const charNode = node.children.get(char);
|
|
202
|
-
if (charNode !== undefined) {
|
|
203
|
-
dfs(charNode, word.concat(char));
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
if (node.isEnd) {
|
|
207
|
-
words.push(word);
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
let startNode = this._root;
|
|
212
|
-
|
|
213
|
-
if (prefix) {
|
|
214
|
-
for (const c of prefix) {
|
|
215
|
-
const nodeC = startNode.children.get(c);
|
|
216
|
-
if (nodeC) startNode = nodeC;
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
dfs(startNode, prefix);
|
|
221
|
-
return words;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
// --- end additional methods ---
|
|
225
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AbstractBinaryTreeNodeProperties,
|
|
3
|
-
AbstractBinaryTreeNodeProperty,
|
|
4
|
-
BinaryTreeDeletedResult,
|
|
5
|
-
BinaryTreeNodeId,
|
|
6
|
-
BinaryTreeNodePropertyName,
|
|
7
|
-
DFSOrderPattern,
|
|
8
|
-
FamilyPosition,
|
|
9
|
-
LoopType,
|
|
10
|
-
NodeOrPropertyName
|
|
11
|
-
} from '../types';
|
|
12
|
-
import {AbstractBinaryTreeNode} from '../data-structures';
|
|
13
|
-
|
|
14
|
-
export interface IAbstractBinaryTreeNode<T, NEIGHBOR extends IAbstractBinaryTreeNode<T, NEIGHBOR>> {
|
|
15
|
-
get id(): BinaryTreeNodeId;
|
|
16
|
-
|
|
17
|
-
set id(v: BinaryTreeNodeId);
|
|
18
|
-
|
|
19
|
-
get val(): T | undefined;
|
|
20
|
-
|
|
21
|
-
set val(v: T | undefined);
|
|
22
|
-
|
|
23
|
-
get left(): NEIGHBOR | null | undefined;
|
|
24
|
-
|
|
25
|
-
set left(v: NEIGHBOR | null | undefined);
|
|
26
|
-
|
|
27
|
-
get right(): NEIGHBOR | null | undefined;
|
|
28
|
-
|
|
29
|
-
set right(v: NEIGHBOR | null | undefined);
|
|
30
|
-
|
|
31
|
-
get parent(): NEIGHBOR | null | undefined;
|
|
32
|
-
|
|
33
|
-
set parent(v: NEIGHBOR | null | undefined);
|
|
34
|
-
|
|
35
|
-
get familyPosition(): FamilyPosition;
|
|
36
|
-
|
|
37
|
-
get height(): number;
|
|
38
|
-
|
|
39
|
-
set height(v: number);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export interface IAbstractBinaryTree<N extends AbstractBinaryTreeNode<N['val'], N>> {
|
|
43
|
-
createNode(id: BinaryTreeNodeId, val?: N['val'], count?: number): N | null;
|
|
44
|
-
|
|
45
|
-
get loopType(): LoopType;
|
|
46
|
-
|
|
47
|
-
get visitedId(): BinaryTreeNodeId[];
|
|
48
|
-
|
|
49
|
-
get visitedVal(): Array<N['val']>;
|
|
50
|
-
|
|
51
|
-
get visitedNode(): N[];
|
|
52
|
-
|
|
53
|
-
get visitedLeftSum(): number[];
|
|
54
|
-
|
|
55
|
-
get root(): N | null;
|
|
56
|
-
|
|
57
|
-
get size(): number;
|
|
58
|
-
|
|
59
|
-
swapLocation(srcNode: N, destNode: N): N;
|
|
60
|
-
|
|
61
|
-
clear(): void;
|
|
62
|
-
|
|
63
|
-
isEmpty(): boolean;
|
|
64
|
-
|
|
65
|
-
add(id: BinaryTreeNodeId | N, val?: N['val']): N | null | undefined;
|
|
66
|
-
|
|
67
|
-
addMany(idsOrNodes: (BinaryTreeNodeId | N | null)[], data?: N['val'][]): (N | null | undefined)[];
|
|
68
|
-
|
|
69
|
-
fill(idsOrNodes: (BinaryTreeNodeId | N | null)[], data?: N[] | Array<N['val']>): boolean;
|
|
70
|
-
|
|
71
|
-
remove(id: BinaryTreeNodeId, ignoreCount?: boolean): BinaryTreeDeletedResult<N>[];
|
|
72
|
-
|
|
73
|
-
getDepth(node: N): number;
|
|
74
|
-
|
|
75
|
-
getHeight(beginRoot?: N | null): number;
|
|
76
|
-
|
|
77
|
-
getMinHeight(beginRoot?: N | null): number;
|
|
78
|
-
|
|
79
|
-
isPerfectlyBalanced(beginRoot?: N | null): boolean;
|
|
80
|
-
|
|
81
|
-
getNodes(nodeProperty: BinaryTreeNodeId | N, propertyName?: BinaryTreeNodePropertyName, onlyOne?: boolean): N[];
|
|
82
|
-
|
|
83
|
-
has(nodeProperty: BinaryTreeNodeId | N, propertyName?: BinaryTreeNodePropertyName): boolean;
|
|
84
|
-
|
|
85
|
-
get(nodeProperty: BinaryTreeNodeId | N, propertyName?: BinaryTreeNodePropertyName): N | null;
|
|
86
|
-
|
|
87
|
-
getPathToRoot(node: N): N[];
|
|
88
|
-
|
|
89
|
-
getLeftMost(): N | null;
|
|
90
|
-
|
|
91
|
-
getLeftMost(node: N): N;
|
|
92
|
-
|
|
93
|
-
getLeftMost(node?: N | null): N | null;
|
|
94
|
-
|
|
95
|
-
getRightMost(): N | null;
|
|
96
|
-
|
|
97
|
-
getRightMost(node: N): N;
|
|
98
|
-
|
|
99
|
-
getRightMost(node?: N | null): N | null;
|
|
100
|
-
|
|
101
|
-
isSubtreeBST(node: N | null): boolean;
|
|
102
|
-
|
|
103
|
-
isBST(): boolean;
|
|
104
|
-
|
|
105
|
-
getSubTreeSize(subTreeRoot: N | null | undefined): number;
|
|
106
|
-
|
|
107
|
-
// --- start additional methods ---
|
|
108
|
-
|
|
109
|
-
subTreeSum(subTreeRoot: N, propertyName?: BinaryTreeNodePropertyName): number;
|
|
110
|
-
|
|
111
|
-
subTreeAdd(subTreeRoot: N, delta: number, propertyName?: BinaryTreeNodePropertyName): boolean;
|
|
112
|
-
|
|
113
|
-
BFS(): BinaryTreeNodeId[];
|
|
114
|
-
|
|
115
|
-
BFS(nodeOrPropertyName: 'id'): BinaryTreeNodeId[];
|
|
116
|
-
|
|
117
|
-
BFS(nodeOrPropertyName: 'val'): N['val'][];
|
|
118
|
-
|
|
119
|
-
BFS(nodeOrPropertyName: 'node'): N[];
|
|
120
|
-
|
|
121
|
-
BFS(nodeOrPropertyName: 'count'): number[];
|
|
122
|
-
|
|
123
|
-
BFS(nodeOrPropertyName?: NodeOrPropertyName): AbstractBinaryTreeNodeProperties<N>;
|
|
124
|
-
|
|
125
|
-
DFS(): BinaryTreeNodeId[];
|
|
126
|
-
|
|
127
|
-
DFS(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'id'): BinaryTreeNodeId[];
|
|
128
|
-
|
|
129
|
-
DFS(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'val'): N[];
|
|
130
|
-
|
|
131
|
-
DFS(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'node'): N[];
|
|
132
|
-
|
|
133
|
-
DFS(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'count'): number[];
|
|
134
|
-
|
|
135
|
-
DFS(pattern?: 'in' | 'pre' | 'post', nodeOrPropertyName?: NodeOrPropertyName): AbstractBinaryTreeNodeProperties<N>;
|
|
136
|
-
|
|
137
|
-
DFSIterative(): BinaryTreeNodeId[];
|
|
138
|
-
|
|
139
|
-
DFSIterative(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'id'): BinaryTreeNodeId[];
|
|
140
|
-
|
|
141
|
-
DFSIterative(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'val'): N[];
|
|
142
|
-
|
|
143
|
-
DFSIterative(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'node'): N[];
|
|
144
|
-
|
|
145
|
-
DFSIterative(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'count'): number[];
|
|
146
|
-
|
|
147
|
-
DFSIterative(
|
|
148
|
-
pattern?: 'in' | 'pre' | 'post',
|
|
149
|
-
nodeOrPropertyName?: NodeOrPropertyName
|
|
150
|
-
): AbstractBinaryTreeNodeProperties<N>;
|
|
151
|
-
|
|
152
|
-
levelIterative(node: N | null): BinaryTreeNodeId[];
|
|
153
|
-
|
|
154
|
-
levelIterative(node: N | null, nodeOrPropertyName?: 'id'): BinaryTreeNodeId[];
|
|
155
|
-
|
|
156
|
-
levelIterative(node: N | null, nodeOrPropertyName?: 'val'): N['val'][];
|
|
157
|
-
|
|
158
|
-
levelIterative(node: N | null, nodeOrPropertyName?: 'node'): N[];
|
|
159
|
-
|
|
160
|
-
levelIterative(node: N | null, nodeOrPropertyName?: 'count'): number[];
|
|
161
|
-
|
|
162
|
-
levelIterative(node: N | null, nodeOrPropertyName?: NodeOrPropertyName): AbstractBinaryTreeNodeProperties<N>;
|
|
163
|
-
|
|
164
|
-
listLevels(node: N | null): BinaryTreeNodeId[][];
|
|
165
|
-
|
|
166
|
-
listLevels(node: N | null, nodeOrPropertyName?: 'id'): BinaryTreeNodeId[][];
|
|
167
|
-
|
|
168
|
-
listLevels(node: N | null, nodeOrPropertyName?: 'val'): N['val'][][];
|
|
169
|
-
|
|
170
|
-
listLevels(node: N | null, nodeOrPropertyName?: 'node'): N[][];
|
|
171
|
-
|
|
172
|
-
listLevels(node: N | null, nodeOrPropertyName?: 'count'): number[][];
|
|
173
|
-
|
|
174
|
-
listLevels(node: N | null, nodeOrPropertyName?: NodeOrPropertyName): AbstractBinaryTreeNodeProperty<N>[][];
|
|
175
|
-
|
|
176
|
-
getPredecessor(node: N): N;
|
|
177
|
-
|
|
178
|
-
morris(): BinaryTreeNodeId[];
|
|
179
|
-
|
|
180
|
-
morris(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'id'): BinaryTreeNodeId[];
|
|
181
|
-
|
|
182
|
-
morris(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'val'): N[];
|
|
183
|
-
|
|
184
|
-
morris(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'node'): N[];
|
|
185
|
-
|
|
186
|
-
morris(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'count'): number[];
|
|
187
|
-
|
|
188
|
-
morris(pattern?: 'in' | 'pre' | 'post', nodeOrPropertyName?: NodeOrPropertyName): AbstractBinaryTreeNodeProperties<N>;
|
|
189
|
-
|
|
190
|
-
// --- end additional methods ---
|
|
191
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import {VertexId} from '../types';
|
|
2
|
-
|
|
3
|
-
export interface IAbstractGraph<V, E> {
|
|
4
|
-
hasVertex(vertexOrId: V | VertexId): boolean;
|
|
5
|
-
|
|
6
|
-
addVertex(id: VertexId, val?: V): boolean;
|
|
7
|
-
|
|
8
|
-
removeVertex(vertexOrId: V | VertexId): boolean;
|
|
9
|
-
|
|
10
|
-
removeAllVertices(vertices: V[] | VertexId[]): boolean;
|
|
11
|
-
|
|
12
|
-
degreeOf(vertexOrId: V | VertexId): number;
|
|
13
|
-
|
|
14
|
-
edgesOf(vertexOrId: V | VertexId): E[];
|
|
15
|
-
|
|
16
|
-
hasEdge(src: V | VertexId, dest: V | VertexId): boolean;
|
|
17
|
-
|
|
18
|
-
getEdge(srcOrId: V | VertexId, destOrId: V | VertexId): E | null;
|
|
19
|
-
|
|
20
|
-
edgeSet(): E[];
|
|
21
|
-
|
|
22
|
-
addEdge(src: V | VertexId, dest: V | VertexId, weight: number, val: E): boolean;
|
|
23
|
-
|
|
24
|
-
removeEdge(edge: E): E | null;
|
|
25
|
-
|
|
26
|
-
setEdgeWeight(srcOrId: V | VertexId, destOrId: V | VertexId, weight: number): boolean;
|
|
27
|
-
|
|
28
|
-
getMinPathBetween(v1: V | VertexId, v2: V | VertexId, isWeight?: boolean): V[] | null;
|
|
29
|
-
|
|
30
|
-
getNeighbors(vertexOrId: V | VertexId): V[];
|
|
31
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import {AVLTreeNode} from '../data-structures';
|
|
2
|
-
import {IBST, IBSTNode} from './bst';
|
|
3
|
-
import {BinaryTreeDeletedResult, BinaryTreeNodeId} from '../types';
|
|
4
|
-
|
|
5
|
-
export type IAVLTreeNode<T, NEIGHBOR extends IAVLTreeNode<T, NEIGHBOR>> = IBSTNode<T, NEIGHBOR>;
|
|
6
|
-
|
|
7
|
-
export interface IAVLTree<N extends AVLTreeNode<N['val'], N>> extends IBST<N> {
|
|
8
|
-
add(id: BinaryTreeNodeId, val?: N['val'] | null): N | null | undefined;
|
|
9
|
-
|
|
10
|
-
remove(id: BinaryTreeNodeId, isUpdateAllLeftSum?: boolean): BinaryTreeDeletedResult<N>[];
|
|
11
|
-
|
|
12
|
-
// _balanceFactor(node: N): number
|
|
13
|
-
//
|
|
14
|
-
// _updateHeight(node: N): void
|
|
15
|
-
//
|
|
16
|
-
// _balancePath(node: N): void
|
|
17
|
-
//
|
|
18
|
-
// _balanceLL(A: N): void
|
|
19
|
-
//
|
|
20
|
-
// _balanceLR(A: N): void
|
|
21
|
-
//
|
|
22
|
-
// _balanceRR(A: N): void
|
|
23
|
-
//
|
|
24
|
-
// _balanceRL(A: N): void
|
|
25
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import {BinaryTreeNode} from '../data-structures';
|
|
2
|
-
import {IAbstractBinaryTree, IAbstractBinaryTreeNode} from './abstract-binary-tree';
|
|
3
|
-
|
|
4
|
-
export type IBinaryTreeNode<T, NEIGHBOR extends IBinaryTreeNode<T, NEIGHBOR>> = IAbstractBinaryTreeNode<T, NEIGHBOR>;
|
|
5
|
-
|
|
6
|
-
export type IBinaryTree<N extends BinaryTreeNode<N['val'], N>> = IAbstractBinaryTree<N>;
|
package/src/interfaces/bst.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import {BSTNode} from '../data-structures';
|
|
2
|
-
import {IBinaryTree, IBinaryTreeNode} from './binary-tree';
|
|
3
|
-
import {BinaryTreeDeletedResult, BinaryTreeNodeId, BinaryTreeNodePropertyName} from '../types';
|
|
4
|
-
|
|
5
|
-
export type IBSTNode<T, NEIGHBOR extends IBSTNode<T, NEIGHBOR>> = IBinaryTreeNode<T, NEIGHBOR>;
|
|
6
|
-
|
|
7
|
-
export interface IBST<N extends BSTNode<N['val'], N>> extends IBinaryTree<N> {
|
|
8
|
-
createNode(id: BinaryTreeNodeId, val?: N['val'], count?: number): N;
|
|
9
|
-
|
|
10
|
-
add(id: BinaryTreeNodeId, val?: N['val'] | null, count?: number): N | null | undefined;
|
|
11
|
-
|
|
12
|
-
get(nodeProperty: BinaryTreeNodeId | N, propertyName?: BinaryTreeNodePropertyName): N | null;
|
|
13
|
-
|
|
14
|
-
lastKey(): BinaryTreeNodeId;
|
|
15
|
-
|
|
16
|
-
remove(id: BinaryTreeNodeId, ignoreCount?: boolean): BinaryTreeDeletedResult<N>[];
|
|
17
|
-
|
|
18
|
-
getNodes(nodeProperty: BinaryTreeNodeId | N, propertyName?: BinaryTreeNodePropertyName, onlyOne?: boolean): N[];
|
|
19
|
-
|
|
20
|
-
// --- start additional functions
|
|
21
|
-
|
|
22
|
-
lesserSum(id: BinaryTreeNodeId, propertyName?: BinaryTreeNodePropertyName): number;
|
|
23
|
-
|
|
24
|
-
allGreaterNodesAdd(node: N, delta: number, propertyName?: BinaryTreeNodePropertyName): boolean;
|
|
25
|
-
|
|
26
|
-
perfectlyBalance(): boolean;
|
|
27
|
-
|
|
28
|
-
isAVLBalanced(): boolean;
|
|
29
|
-
|
|
30
|
-
// --- end additional functions
|
|
31
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import {VertexId} from '../types';
|
|
2
|
-
import {IAbstractGraph} from './abstract-graph';
|
|
3
|
-
|
|
4
|
-
export interface IDirectedGraph<V, E> extends IAbstractGraph<V, E> {
|
|
5
|
-
incomingEdgesOf(vertex: V): E[];
|
|
6
|
-
|
|
7
|
-
outgoingEdgesOf(vertex: V): E[];
|
|
8
|
-
|
|
9
|
-
inDegreeOf(vertexOrId: V | VertexId): number;
|
|
10
|
-
|
|
11
|
-
outDegreeOf(vertexOrId: V | VertexId): number;
|
|
12
|
-
|
|
13
|
-
getEdgeSrc(e: E): V | null;
|
|
14
|
-
|
|
15
|
-
getEdgeDest(e: E): V | null;
|
|
16
|
-
|
|
17
|
-
removeEdgeSrcToDest(srcOrId: V | VertexId, destOrId: V | VertexId): E | null;
|
|
18
|
-
|
|
19
|
-
removeEdgesBetween(v1: V | VertexId, v2: V | VertexId): E[];
|
|
20
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/src/interfaces/heap.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/src/interfaces/index.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export * from './abstract-binary-tree';
|
|
2
|
-
export * from './abstract-graph';
|
|
3
|
-
export * from './avl-tree';
|
|
4
|
-
export * from './binary-tree';
|
|
5
|
-
export * from './bst';
|
|
6
|
-
export * from './directed-graph';
|
|
7
|
-
export * from './doubly-linked-list';
|
|
8
|
-
export * from './heap';
|
|
9
|
-
export * from './navigator';
|
|
10
|
-
export * from './priority-queue';
|
|
11
|
-
export * from './rb-tree';
|
|
12
|
-
export * from './segment-tree';
|
|
13
|
-
export * from './singly-linked-list';
|
|
14
|
-
export * from './tree-multiset';
|
|
15
|
-
export * from './undirected-graph';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import {RBTreeNode} from '../data-structures';
|
|
2
|
-
import {IBST, IBSTNode} from './bst';
|
|
3
|
-
import {BinaryTreeNodeId} from '../types';
|
|
4
|
-
|
|
5
|
-
export type IRBTreeNode<T, NEIGHBOR extends IRBTreeNode<T, NEIGHBOR>> = IBSTNode<T, NEIGHBOR>;
|
|
6
|
-
|
|
7
|
-
export interface IRBTree<N extends RBTreeNode<N['val'], N>> extends IBST<N> {
|
|
8
|
-
createNode(id: BinaryTreeNodeId, val?: N['val'], count?: number): N;
|
|
9
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import {TreeMultisetNode} from '../data-structures';
|
|
2
|
-
import {IBSTNode} from './bst';
|
|
3
|
-
import {IAVLTree} from './avl-tree';
|
|
4
|
-
|
|
5
|
-
export type ITreeMultisetNode<T, NEIGHBOR extends ITreeMultisetNode<T, NEIGHBOR>> = IBSTNode<T, NEIGHBOR>;
|
|
6
|
-
|
|
7
|
-
export type ITreeMultiset<N extends TreeMultisetNode<N['val'], N>> = IAVLTree<N>;
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import {AbstractBinaryTreeNode} from '../../data-structures';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Enum representing different loop types.
|
|
5
|
-
*
|
|
6
|
-
* - `iterative`: Indicates the iterative loop type (with loops that use iterations).
|
|
7
|
-
* - `recursive`: Indicates the recursive loop type (with loops that call themselves).
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
export enum LoopType {
|
|
11
|
-
ITERATIVE = 'ITERATIVE',
|
|
12
|
-
RECURSIVE = 'RECURSIVE'
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/* This enumeration defines the position of a node within a family tree composed of three associated nodes, where 'root' represents the root node of the family tree, 'left' represents the left child node, and 'right' represents the right child node. */
|
|
16
|
-
export enum FamilyPosition {
|
|
17
|
-
ROOT = 'ROOT',
|
|
18
|
-
LEFT = 'LEFT',
|
|
19
|
-
RIGHT = 'RIGHT',
|
|
20
|
-
ROOT_LEFT = 'ROOT_LEFT',
|
|
21
|
-
ROOT_RIGHT = 'ROOT_RIGHT',
|
|
22
|
-
ISOLATED = 'ISOLATED',
|
|
23
|
-
MAL_NODE = 'MAL_NODE'
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export type BinaryTreeNodePropertyName = 'id' | 'val';
|
|
27
|
-
|
|
28
|
-
export type NodeOrPropertyName = 'node' | BinaryTreeNodePropertyName;
|
|
29
|
-
|
|
30
|
-
export type DFSOrderPattern = 'in' | 'pre' | 'post';
|
|
31
|
-
|
|
32
|
-
export type BinaryTreeNodeId = number;
|
|
33
|
-
|
|
34
|
-
export type BinaryTreeDeletedResult<N> = { deleted: N | null | undefined; needBalanced: N | null };
|
|
35
|
-
|
|
36
|
-
export type AbstractBinaryTreeNodeProperty<N extends AbstractBinaryTreeNode<N['val'], N>> =
|
|
37
|
-
| N['val']
|
|
38
|
-
| N
|
|
39
|
-
| number
|
|
40
|
-
| BinaryTreeNodeId;
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
export type AbstractBinaryTreeNodeProperties<N extends AbstractBinaryTreeNode<N['val'], N>> =
|
|
44
|
-
AbstractBinaryTreeNodeProperty<N>[];
|
|
45
|
-
|
|
46
|
-
export type AbstractBinaryTreeNodeNested<T> = AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
|
|
47
|
-
|
|
48
|
-
export type AbstractBinaryTreeOptions = {
|
|
49
|
-
loopType?: LoopType
|
|
50
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export type VertexId = string | number;
|
|
2
|
-
export type EdgeId = string;
|
|
3
|
-
export type DijkstraResult<V> = {
|
|
4
|
-
distMap: Map<V, number>;
|
|
5
|
-
distPaths?: Map<V, V[]>;
|
|
6
|
-
preMap: Map<V, V | null>;
|
|
7
|
-
seen: Set<V>;
|
|
8
|
-
paths: V[][];
|
|
9
|
-
minDist: number;
|
|
10
|
-
minPath: V[];
|
|
11
|
-
} | null;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import {AVLTreeNode} from '../../data-structures';
|
|
2
|
-
import {BSTOptions} from './bst';
|
|
3
|
-
|
|
4
|
-
export type AVLTreeNodeNested<T> = AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
|
5
|
-
export type AVLTreeOptions = BSTOptions & {};
|