data-structure-typed 1.20.0 → 1.21.1
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/LICENSE +21 -0
- package/README.md +9 -56
- package/dist/data-structures/binary-tree/abstract-binary-tree.d.ts +11 -18
- package/dist/data-structures/binary-tree/abstract-binary-tree.js +52 -74
- package/dist/data-structures/binary-tree/tree-multiset.d.ts +6 -6
- package/dist/data-structures/binary-tree/tree-multiset.js +20 -28
- package/dist/data-structures/graph/abstract-graph.d.ts +3 -3
- package/dist/data-structures/graph/abstract-graph.js +6 -2
- package/dist/data-structures/graph/index.d.ts +1 -0
- package/dist/data-structures/graph/index.js +1 -0
- package/dist/data-structures/graph/map-graph.d.ts +79 -0
- package/dist/data-structures/graph/map-graph.js +111 -0
- package/dist/data-structures/interfaces/abstract-binary-tree.d.ts +0 -2
- package/dist/data-structures/tree/tree.d.ts +1 -1
- package/dist/data-structures/types/abstract-binary-tree.d.ts +0 -1
- package/dist/data-structures/types/abstract-graph.d.ts +1 -0
- package/dist/data-structures/types/index.d.ts +1 -0
- package/dist/data-structures/types/index.js +1 -0
- package/dist/data-structures/types/map-graph.d.ts +1 -0
- package/dist/data-structures/types/map-graph.js +2 -0
- package/dist/data-structures/types/tree-multiset.d.ts +1 -3
- package/package.json +21 -20
- package/src/data-structures/binary-tree/aa-tree.ts +0 -3
- package/src/data-structures/binary-tree/abstract-binary-tree.ts +0 -1479
- package/src/data-structures/binary-tree/avl-tree.ts +0 -301
- package/src/data-structures/binary-tree/b-tree.ts +0 -3
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +0 -78
- package/src/data-structures/binary-tree/binary-tree.ts +0 -42
- package/src/data-structures/binary-tree/bst.ts +0 -438
- package/src/data-structures/binary-tree/index.ts +0 -12
- package/src/data-structures/binary-tree/rb-tree.ts +0 -102
- package/src/data-structures/binary-tree/segment-tree.ts +0 -243
- package/src/data-structures/binary-tree/splay-tree.ts +0 -3
- package/src/data-structures/binary-tree/tree-multiset.ts +0 -712
- package/src/data-structures/binary-tree/two-three-tree.ts +0 -3
- package/src/data-structures/diagrams/README.md +0 -5
- package/src/data-structures/graph/abstract-graph.ts +0 -1033
- package/src/data-structures/graph/directed-graph.ts +0 -472
- package/src/data-structures/graph/index.ts +0 -3
- package/src/data-structures/graph/undirected-graph.ts +0 -270
- 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 -3
- package/src/data-structures/hash/index.ts +0 -6
- package/src/data-structures/hash/pair.ts +0 -3
- package/src/data-structures/hash/tree-map.ts +0 -3
- package/src/data-structures/hash/tree-set.ts +0 -3
- package/src/data-structures/heap/heap.ts +0 -200
- 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 -34
- package/src/data-structures/index.ts +0 -15
- package/src/data-structures/interfaces/abstract-binary-tree.ts +0 -194
- package/src/data-structures/interfaces/abstract-graph.ts +0 -40
- package/src/data-structures/interfaces/avl-tree.ts +0 -28
- package/src/data-structures/interfaces/binary-tree.ts +0 -8
- package/src/data-structures/interfaces/bst.ts +0 -32
- package/src/data-structures/interfaces/directed-graph.ts +0 -20
- package/src/data-structures/interfaces/doubly-linked-list.ts +0 -1
- package/src/data-structures/interfaces/heap.ts +0 -1
- package/src/data-structures/interfaces/index.ts +0 -15
- package/src/data-structures/interfaces/navigator.ts +0 -1
- package/src/data-structures/interfaces/priority-queue.ts +0 -1
- package/src/data-structures/interfaces/rb-tree.ts +0 -11
- package/src/data-structures/interfaces/segment-tree.ts +0 -1
- package/src/data-structures/interfaces/singly-linked-list.ts +0 -1
- package/src/data-structures/interfaces/tree-multiset.ts +0 -12
- package/src/data-structures/interfaces/undirected-graph.ts +0 -6
- 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 -490
- package/src/data-structures/linked-list/skip-linked-list.ts +0 -3
- 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 -208
- package/src/data-structures/matrix/navigator.ts +0 -122
- 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 -49
- package/src/data-structures/priority-queue/min-priority-queue.ts +0 -50
- package/src/data-structures/priority-queue/priority-queue.ts +0 -354
- package/src/data-structures/queue/deque.ts +0 -251
- package/src/data-structures/queue/index.ts +0 -2
- package/src/data-structures/queue/queue.ts +0 -120
- 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 -227
- package/src/data-structures/types/abstract-binary-tree.ts +0 -41
- package/src/data-structures/types/abstract-graph.ts +0 -5
- package/src/data-structures/types/avl-tree.ts +0 -5
- package/src/data-structures/types/binary-tree.ts +0 -9
- package/src/data-structures/types/bst.ts +0 -12
- package/src/data-structures/types/directed-graph.ts +0 -8
- package/src/data-structures/types/doubly-linked-list.ts +0 -1
- package/src/data-structures/types/heap.ts +0 -5
- package/src/data-structures/types/helpers.ts +0 -1
- package/src/data-structures/types/index.ts +0 -15
- package/src/data-structures/types/navigator.ts +0 -13
- package/src/data-structures/types/priority-queue.ts +0 -9
- package/src/data-structures/types/rb-tree.ts +0 -8
- package/src/data-structures/types/segment-tree.ts +0 -1
- package/src/data-structures/types/singly-linked-list.ts +0 -1
- package/src/data-structures/types/tree-multiset.ts +0 -8
- package/src/index.ts +0 -2
- package/src/utils/index.ts +0 -3
- package/src/utils/types/index.ts +0 -2
- package/src/utils/types/utils.ts +0 -6
- package/src/utils/types/validate-type.ts +0 -25
- package/src/utils/utils.ts +0 -78
- package/src/utils/validate-type.ts +0 -69
|
@@ -1,34 +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
|
-
|
|
9
|
-
import {Heap, HeapItem} from './heap';
|
|
10
|
-
import {PriorityQueue} from '../priority-queue';
|
|
11
|
-
import type {HeapOptions} from '../types';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* @class MinHeap
|
|
15
|
-
* @extends Heap
|
|
16
|
-
*/
|
|
17
|
-
export class MinHeap<T = number> extends Heap<T> {
|
|
18
|
-
protected _pq: PriorityQueue<HeapItem<T>>;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* The constructor initializes a PriorityQueue with a comparator function that compares the priority of two HeapItem
|
|
22
|
-
* objects.
|
|
23
|
-
* @param [options] - The `options` parameter is an optional object that can be passed to the constructor. It is of
|
|
24
|
-
* type `HeapOptions<T>`, which is a generic type that represents the options for the heap.
|
|
25
|
-
*/
|
|
26
|
-
constructor(options?: HeapOptions<T>) {
|
|
27
|
-
super(options);
|
|
28
|
-
this._pq = new PriorityQueue<HeapItem<T>>({
|
|
29
|
-
comparator: (a, b) => a.priority - b.priority
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export * from './hash';
|
|
2
|
-
export * from './linked-list';
|
|
3
|
-
export * from './stack';
|
|
4
|
-
export * from './queue';
|
|
5
|
-
export * from './graph';
|
|
6
|
-
export * from './binary-tree';
|
|
7
|
-
export * from './tree';
|
|
8
|
-
export * from './heap';
|
|
9
|
-
export * from './priority-queue';
|
|
10
|
-
export * from './matrix';
|
|
11
|
-
export * from './trie';
|
|
12
|
-
export * from './interfaces';
|
|
13
|
-
export * from './types';
|
|
14
|
-
|
|
15
|
-
|
|
@@ -1,194 +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 '../binary-tree';
|
|
13
|
-
|
|
14
|
-
export interface IAbstractBinaryTreeNode<T, NEIGHBOR extends IAbstractBinaryTreeNode<T, NEIGHBOR>> {
|
|
15
|
-
|
|
16
|
-
get id(): BinaryTreeNodeId
|
|
17
|
-
|
|
18
|
-
set id(v: BinaryTreeNodeId)
|
|
19
|
-
|
|
20
|
-
get val(): T | undefined
|
|
21
|
-
|
|
22
|
-
set val(v: T | undefined)
|
|
23
|
-
|
|
24
|
-
get left(): NEIGHBOR | null | undefined
|
|
25
|
-
|
|
26
|
-
set left(v: NEIGHBOR | null | undefined)
|
|
27
|
-
|
|
28
|
-
get right(): NEIGHBOR | null | undefined
|
|
29
|
-
|
|
30
|
-
set right(v: NEIGHBOR | null | undefined)
|
|
31
|
-
|
|
32
|
-
get parent(): NEIGHBOR | null | undefined
|
|
33
|
-
|
|
34
|
-
set parent(v: NEIGHBOR | null | undefined)
|
|
35
|
-
|
|
36
|
-
get familyPosition(): FamilyPosition
|
|
37
|
-
|
|
38
|
-
get height(): number
|
|
39
|
-
|
|
40
|
-
set height(v: number)
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export interface IAbstractBinaryTree<N extends AbstractBinaryTreeNode<N['val'], N>> {
|
|
44
|
-
createNode(id: BinaryTreeNodeId, val?: N['val'], count?: number): N | null
|
|
45
|
-
|
|
46
|
-
get loopType(): LoopType
|
|
47
|
-
|
|
48
|
-
get visitedId(): BinaryTreeNodeId[]
|
|
49
|
-
|
|
50
|
-
get visitedVal(): Array<N['val']>
|
|
51
|
-
|
|
52
|
-
get visitedNode(): N[]
|
|
53
|
-
|
|
54
|
-
get visitedLeftSum(): number[]
|
|
55
|
-
|
|
56
|
-
get isMergeDuplicatedNodeById(): boolean
|
|
57
|
-
|
|
58
|
-
get root(): N | null
|
|
59
|
-
|
|
60
|
-
get size(): number
|
|
61
|
-
|
|
62
|
-
swapLocation(srcNode: N, destNode: N): N
|
|
63
|
-
|
|
64
|
-
clear(): void
|
|
65
|
-
|
|
66
|
-
isEmpty(): boolean
|
|
67
|
-
|
|
68
|
-
add(id: BinaryTreeNodeId | N, val?: N['val']): N | null | undefined
|
|
69
|
-
|
|
70
|
-
addTo(newNode: N | null, parent: N): N | null | undefined
|
|
71
|
-
|
|
72
|
-
addMany(idsOrNodes: (BinaryTreeNodeId | N | null)[], data?: N['val'][]): (N | null | undefined)[]
|
|
73
|
-
|
|
74
|
-
fill(idsOrNodes: (BinaryTreeNodeId | N | null)[], data?: N[] | Array<N['val']>): boolean
|
|
75
|
-
|
|
76
|
-
remove(id: BinaryTreeNodeId, ignoreCount?: boolean): BinaryTreeDeletedResult<N>[]
|
|
77
|
-
|
|
78
|
-
getDepth(node: N): number
|
|
79
|
-
|
|
80
|
-
getHeight(beginRoot?: N | null): number
|
|
81
|
-
|
|
82
|
-
getMinHeight(beginRoot?: N | null): number
|
|
83
|
-
|
|
84
|
-
isPerfectlyBalanced(beginRoot?: N | null): boolean
|
|
85
|
-
|
|
86
|
-
getNodes(nodeProperty: BinaryTreeNodeId | N, propertyName ?: BinaryTreeNodePropertyName, onlyOne ?: boolean): N[]
|
|
87
|
-
|
|
88
|
-
has(nodeProperty: BinaryTreeNodeId | N, propertyName ?: BinaryTreeNodePropertyName): boolean
|
|
89
|
-
|
|
90
|
-
get(nodeProperty: BinaryTreeNodeId | N, propertyName ?: BinaryTreeNodePropertyName): N | null
|
|
91
|
-
|
|
92
|
-
getPathToRoot(node: N): N[]
|
|
93
|
-
|
|
94
|
-
getLeftMost(): N | null;
|
|
95
|
-
|
|
96
|
-
getLeftMost(node: N): N;
|
|
97
|
-
|
|
98
|
-
getLeftMost(node?: N | null): N | null
|
|
99
|
-
|
|
100
|
-
getRightMost(): N | null;
|
|
101
|
-
|
|
102
|
-
getRightMost(node: N): N;
|
|
103
|
-
|
|
104
|
-
getRightMost(node?: N | null): N | null
|
|
105
|
-
|
|
106
|
-
isSubtreeBST(node: N | null): boolean
|
|
107
|
-
|
|
108
|
-
isBST(): boolean
|
|
109
|
-
|
|
110
|
-
getSubTreeSize(subTreeRoot: N | null | undefined): number
|
|
111
|
-
|
|
112
|
-
// --- start additional methods ---
|
|
113
|
-
|
|
114
|
-
subTreeSum(subTreeRoot: N, propertyName ?: BinaryTreeNodePropertyName): number
|
|
115
|
-
|
|
116
|
-
subTreeAdd(subTreeRoot: N, delta: number, propertyName ?: BinaryTreeNodePropertyName): boolean
|
|
117
|
-
|
|
118
|
-
BFS(): BinaryTreeNodeId[];
|
|
119
|
-
|
|
120
|
-
BFS(nodeOrPropertyName: 'id'): BinaryTreeNodeId[];
|
|
121
|
-
|
|
122
|
-
BFS(nodeOrPropertyName: 'val'): N['val'][];
|
|
123
|
-
|
|
124
|
-
BFS(nodeOrPropertyName: 'node'): N[];
|
|
125
|
-
|
|
126
|
-
BFS(nodeOrPropertyName: 'count'): number[];
|
|
127
|
-
|
|
128
|
-
BFS(nodeOrPropertyName ?: NodeOrPropertyName): AbstractBinaryTreeNodeProperties<N>
|
|
129
|
-
|
|
130
|
-
DFS(): BinaryTreeNodeId[];
|
|
131
|
-
|
|
132
|
-
DFS(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'id'): BinaryTreeNodeId[];
|
|
133
|
-
|
|
134
|
-
DFS(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'val'): N[];
|
|
135
|
-
|
|
136
|
-
DFS(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'node'): N[];
|
|
137
|
-
|
|
138
|
-
DFS(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'count'): number[];
|
|
139
|
-
|
|
140
|
-
DFS(pattern ?: 'in' | 'pre' | 'post', nodeOrPropertyName ?: NodeOrPropertyName): AbstractBinaryTreeNodeProperties<N>
|
|
141
|
-
|
|
142
|
-
DFSIterative(): BinaryTreeNodeId[];
|
|
143
|
-
|
|
144
|
-
DFSIterative(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'id'): BinaryTreeNodeId[];
|
|
145
|
-
|
|
146
|
-
DFSIterative(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'val'): N[];
|
|
147
|
-
|
|
148
|
-
DFSIterative(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'node'): N[];
|
|
149
|
-
|
|
150
|
-
DFSIterative(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'count'): number[];
|
|
151
|
-
|
|
152
|
-
DFSIterative(pattern ?: 'in' | 'pre' | 'post', nodeOrPropertyName ?: NodeOrPropertyName): AbstractBinaryTreeNodeProperties<N>
|
|
153
|
-
|
|
154
|
-
levelIterative(node: N | null): BinaryTreeNodeId[];
|
|
155
|
-
|
|
156
|
-
levelIterative(node: N | null, nodeOrPropertyName?: 'id'): BinaryTreeNodeId[];
|
|
157
|
-
|
|
158
|
-
levelIterative(node: N | null, nodeOrPropertyName?: 'val'): N['val'][];
|
|
159
|
-
|
|
160
|
-
levelIterative(node: N | null, nodeOrPropertyName?: 'node'): N[];
|
|
161
|
-
|
|
162
|
-
levelIterative(node: N | null, nodeOrPropertyName?: 'count'): number[];
|
|
163
|
-
|
|
164
|
-
levelIterative(node: N | null, nodeOrPropertyName ?: NodeOrPropertyName): AbstractBinaryTreeNodeProperties<N>
|
|
165
|
-
|
|
166
|
-
listLevels(node: N | null): BinaryTreeNodeId[][];
|
|
167
|
-
|
|
168
|
-
listLevels(node: N | null, nodeOrPropertyName?: 'id'): BinaryTreeNodeId[][];
|
|
169
|
-
|
|
170
|
-
listLevels(node: N | null, nodeOrPropertyName?: 'val'): N['val'][][];
|
|
171
|
-
|
|
172
|
-
listLevels(node: N | null, nodeOrPropertyName?: 'node'): N[][];
|
|
173
|
-
|
|
174
|
-
listLevels(node: N | null, nodeOrPropertyName?: 'count'): number[][];
|
|
175
|
-
|
|
176
|
-
listLevels(node: N | null, nodeOrPropertyName?: NodeOrPropertyName): AbstractBinaryTreeNodeProperty<N>[][]
|
|
177
|
-
|
|
178
|
-
getPredecessor(node: N): N
|
|
179
|
-
|
|
180
|
-
morris(): BinaryTreeNodeId[];
|
|
181
|
-
|
|
182
|
-
morris(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'id'): BinaryTreeNodeId[];
|
|
183
|
-
|
|
184
|
-
morris(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'val'): N[];
|
|
185
|
-
|
|
186
|
-
morris(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'node'): N[];
|
|
187
|
-
|
|
188
|
-
morris(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'count'): number[];
|
|
189
|
-
|
|
190
|
-
morris(pattern?: 'in' | 'pre' | 'post', nodeOrPropertyName?: NodeOrPropertyName): AbstractBinaryTreeNodeProperties<N>
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
// --- end additional methods ---
|
|
194
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import {VertexId} from '../types';
|
|
2
|
-
|
|
3
|
-
export interface IAbstractGraph<V, E> {
|
|
4
|
-
|
|
5
|
-
hasVertex(vertexOrId: V | VertexId): boolean;
|
|
6
|
-
|
|
7
|
-
// _getVertex(vertexOrId: VertexId | V): V | null;
|
|
8
|
-
|
|
9
|
-
// _getVertexId(vertexOrId: V | VertexId): VertexId;
|
|
10
|
-
|
|
11
|
-
addVertex(id: VertexId, val?: V): boolean;
|
|
12
|
-
|
|
13
|
-
// _addVertexOnly(newVertex: V): boolean;
|
|
14
|
-
|
|
15
|
-
removeVertex(vertexOrId: V | VertexId): boolean;
|
|
16
|
-
|
|
17
|
-
removeAllVertices(vertices: V[] | VertexId[]): boolean;
|
|
18
|
-
|
|
19
|
-
degreeOf(vertexOrId: V | VertexId): number;
|
|
20
|
-
|
|
21
|
-
edgesOf(vertexOrId: V | VertexId): E[];
|
|
22
|
-
|
|
23
|
-
hasEdge(src: V | VertexId, dest: V | VertexId): boolean;
|
|
24
|
-
|
|
25
|
-
getEdge(srcOrId: V | VertexId, destOrId: V | VertexId): E | null;
|
|
26
|
-
|
|
27
|
-
edgeSet(): E[];
|
|
28
|
-
|
|
29
|
-
addEdge(src: V | VertexId, dest: V | VertexId, weight: number, val: E): boolean;
|
|
30
|
-
|
|
31
|
-
// _addEdgeOnly(edge: E): boolean;
|
|
32
|
-
|
|
33
|
-
removeEdge(edge: E): E | null;
|
|
34
|
-
|
|
35
|
-
setEdgeWeight(srcOrId: V | VertexId, destOrId: V | VertexId, weight: number): boolean;
|
|
36
|
-
|
|
37
|
-
getMinPathBetween(v1: V | VertexId, v2: V | VertexId, isWeight?: boolean): V[] | null;
|
|
38
|
-
|
|
39
|
-
getNeighbors(vertexOrId: V | VertexId): V[];
|
|
40
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import {AVLTreeNode} from '../binary-tree';
|
|
2
|
-
import {IBST, IBSTNode} from './bst';
|
|
3
|
-
import {BinaryTreeDeletedResult, BinaryTreeNodeId} from '../types';
|
|
4
|
-
|
|
5
|
-
export interface IAVLTreeNode<T, NEIGHBOR extends IAVLTreeNode<T, NEIGHBOR>> extends IBSTNode<T, NEIGHBOR> {
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export interface IAVLTree<N extends AVLTreeNode<N['val'], N>> extends IBST<N> {
|
|
10
|
-
|
|
11
|
-
add(id: BinaryTreeNodeId, val?: N['val'] | null): N | null | undefined
|
|
12
|
-
|
|
13
|
-
remove(id: BinaryTreeNodeId, isUpdateAllLeftSum?: boolean): BinaryTreeDeletedResult<N>[]
|
|
14
|
-
|
|
15
|
-
balanceFactor(node: N): number
|
|
16
|
-
|
|
17
|
-
updateHeight(node: N): void
|
|
18
|
-
|
|
19
|
-
balancePath(node: N): void
|
|
20
|
-
|
|
21
|
-
balanceLL(A: N): void
|
|
22
|
-
|
|
23
|
-
balanceLR(A: N): void
|
|
24
|
-
|
|
25
|
-
balanceRR(A: N): void
|
|
26
|
-
|
|
27
|
-
balanceRL(A: N): void
|
|
28
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import {BinaryTreeNode} from '../binary-tree';
|
|
2
|
-
import {IAbstractBinaryTree, IAbstractBinaryTreeNode} from './abstract-binary-tree';
|
|
3
|
-
|
|
4
|
-
export interface IBinaryTreeNode<T, NEIGHBOR extends IBinaryTreeNode<T, NEIGHBOR>> extends IAbstractBinaryTreeNode<T, NEIGHBOR> {
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export interface IBinaryTree<N extends BinaryTreeNode<N['val'], N>> extends IAbstractBinaryTree<N> {
|
|
8
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import {BSTNode} from '../binary-tree';
|
|
2
|
-
import {IBinaryTree, IBinaryTreeNode} from './binary-tree';
|
|
3
|
-
import {BinaryTreeDeletedResult, BinaryTreeNodeId, BinaryTreeNodePropertyName} from '../types';
|
|
4
|
-
|
|
5
|
-
export interface IBSTNode<T, NEIGHBOR extends IBSTNode<T, NEIGHBOR>> extends IBinaryTreeNode<T, NEIGHBOR> {
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export interface IBST<N extends BSTNode<N['val'], N>> extends IBinaryTree<N> {
|
|
9
|
-
createNode(id: BinaryTreeNodeId, val?: N['val'], count?: number): N
|
|
10
|
-
|
|
11
|
-
add(id: BinaryTreeNodeId, val?: N['val'] | null, count?: number): N | null | undefined
|
|
12
|
-
|
|
13
|
-
get(nodeProperty: BinaryTreeNodeId | N, propertyName ?: BinaryTreeNodePropertyName): N | null
|
|
14
|
-
|
|
15
|
-
lastKey(): BinaryTreeNodeId
|
|
16
|
-
|
|
17
|
-
remove(id: BinaryTreeNodeId, ignoreCount?: boolean): BinaryTreeDeletedResult<N>[]
|
|
18
|
-
|
|
19
|
-
getNodes(nodeProperty: BinaryTreeNodeId | N, propertyName ?: BinaryTreeNodePropertyName, onlyOne ?: boolean): N[]
|
|
20
|
-
|
|
21
|
-
// --- start additional functions
|
|
22
|
-
|
|
23
|
-
lesserSum(id: BinaryTreeNodeId, propertyName ?: BinaryTreeNodePropertyName): number
|
|
24
|
-
|
|
25
|
-
allGreaterNodesAdd(node: N, delta: number, propertyName ?: BinaryTreeNodePropertyName): boolean
|
|
26
|
-
|
|
27
|
-
perfectlyBalance(): boolean
|
|
28
|
-
|
|
29
|
-
isAVLBalanced(): boolean
|
|
30
|
-
|
|
31
|
-
// --- end additional functions
|
|
32
|
-
}
|
|
@@ -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 {}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {}
|
|
@@ -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,11 +0,0 @@
|
|
|
1
|
-
import {RBTreeNode} from '../binary-tree';
|
|
2
|
-
import {IBST, IBSTNode} from './bst';
|
|
3
|
-
import {BinaryTreeNodeId} from '../types';
|
|
4
|
-
|
|
5
|
-
export interface IRBTreeNode<T, NEIGHBOR extends IRBTreeNode<T, NEIGHBOR>> extends IBSTNode<T, NEIGHBOR> {
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export interface IRBTree<N extends RBTreeNode<N['val'], N>> extends IBST<N> {
|
|
9
|
-
|
|
10
|
-
createNode(id: BinaryTreeNodeId, val?: N['val'], count?: number): N
|
|
11
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import {TreeMultisetNode} from '../binary-tree';
|
|
2
|
-
import {IBSTNode} from './bst';
|
|
3
|
-
import {IAVLTree} from './avl-tree';
|
|
4
|
-
|
|
5
|
-
export interface ITreeMultisetNode<T, NEIGHBOR extends ITreeMultisetNode<T, NEIGHBOR>> extends IBSTNode<T, NEIGHBOR> {
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export interface ITreeMultiset<N extends TreeMultisetNode<N['val'], N>> extends IAVLTree<N> {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|