data-structure-typed 1.33.8 → 1.33.9

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.
Files changed (148) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/package.json +1 -1
  3. package/.prettierrc.js +0 -16
  4. package/coverage/coverage-final.json +0 -68
  5. package/coverage/coverage-summary.json +0 -69
  6. package/docs/.nojekyll +0 -1
  7. package/docs/index.html +0 -877
  8. package/docs/modules.html +0 -336
  9. package/jest.config.js +0 -8
  10. package/src/data-structures/binary-tree/aa-tree.ts +0 -1
  11. package/src/data-structures/binary-tree/abstract-binary-tree.ts +0 -1608
  12. package/src/data-structures/binary-tree/avl-tree.ts +0 -307
  13. package/src/data-structures/binary-tree/b-tree.ts +0 -1
  14. package/src/data-structures/binary-tree/binary-indexed-tree.ts +0 -76
  15. package/src/data-structures/binary-tree/binary-tree.ts +0 -47
  16. package/src/data-structures/binary-tree/bst.ts +0 -537
  17. package/src/data-structures/binary-tree/index.ts +0 -12
  18. package/src/data-structures/binary-tree/rb-tree.ts +0 -366
  19. package/src/data-structures/binary-tree/segment-tree.ts +0 -260
  20. package/src/data-structures/binary-tree/splay-tree.ts +0 -1
  21. package/src/data-structures/binary-tree/tree-multiset.ts +0 -700
  22. package/src/data-structures/binary-tree/two-three-tree.ts +0 -1
  23. package/src/data-structures/graph/abstract-graph.ts +0 -1040
  24. package/src/data-structures/graph/directed-graph.ts +0 -470
  25. package/src/data-structures/graph/index.ts +0 -4
  26. package/src/data-structures/graph/map-graph.ts +0 -129
  27. package/src/data-structures/graph/undirected-graph.ts +0 -274
  28. package/src/data-structures/hash/coordinate-map.ts +0 -67
  29. package/src/data-structures/hash/coordinate-set.ts +0 -56
  30. package/src/data-structures/hash/hash-map.ts +0 -203
  31. package/src/data-structures/hash/hash-table.ts +0 -277
  32. package/src/data-structures/hash/index.ts +0 -7
  33. package/src/data-structures/hash/pair.ts +0 -1
  34. package/src/data-structures/hash/tree-map.ts +0 -1
  35. package/src/data-structures/hash/tree-set.ts +0 -1
  36. package/src/data-structures/heap/heap.ts +0 -212
  37. package/src/data-structures/heap/index.ts +0 -3
  38. package/src/data-structures/heap/max-heap.ts +0 -31
  39. package/src/data-structures/heap/min-heap.ts +0 -32
  40. package/src/data-structures/index.ts +0 -11
  41. package/src/data-structures/linked-list/doubly-linked-list.ts +0 -636
  42. package/src/data-structures/linked-list/index.ts +0 -3
  43. package/src/data-structures/linked-list/singly-linked-list.ts +0 -501
  44. package/src/data-structures/linked-list/skip-linked-list.ts +0 -166
  45. package/src/data-structures/matrix/index.ts +0 -4
  46. package/src/data-structures/matrix/matrix.ts +0 -27
  47. package/src/data-structures/matrix/matrix2d.ts +0 -213
  48. package/src/data-structures/matrix/navigator.ts +0 -121
  49. package/src/data-structures/matrix/vector2d.ts +0 -316
  50. package/src/data-structures/priority-queue/index.ts +0 -3
  51. package/src/data-structures/priority-queue/max-priority-queue.ts +0 -56
  52. package/src/data-structures/priority-queue/min-priority-queue.ts +0 -57
  53. package/src/data-structures/priority-queue/priority-queue.ts +0 -359
  54. package/src/data-structures/queue/deque.ts +0 -297
  55. package/src/data-structures/queue/index.ts +0 -2
  56. package/src/data-structures/queue/queue.ts +0 -191
  57. package/src/data-structures/stack/index.ts +0 -1
  58. package/src/data-structures/stack/stack.ts +0 -98
  59. package/src/data-structures/tree/index.ts +0 -1
  60. package/src/data-structures/tree/tree.ts +0 -69
  61. package/src/data-structures/trie/index.ts +0 -1
  62. package/src/data-structures/trie/trie.ts +0 -225
  63. package/src/index.ts +0 -4
  64. package/src/interfaces/abstract-binary-tree.ts +0 -189
  65. package/src/interfaces/abstract-graph.ts +0 -31
  66. package/src/interfaces/avl-tree.ts +0 -25
  67. package/src/interfaces/binary-tree.ts +0 -6
  68. package/src/interfaces/bst.ts +0 -31
  69. package/src/interfaces/directed-graph.ts +0 -20
  70. package/src/interfaces/doubly-linked-list.ts +0 -1
  71. package/src/interfaces/heap.ts +0 -1
  72. package/src/interfaces/index.ts +0 -15
  73. package/src/interfaces/navigator.ts +0 -1
  74. package/src/interfaces/priority-queue.ts +0 -1
  75. package/src/interfaces/rb-tree.ts +0 -9
  76. package/src/interfaces/segment-tree.ts +0 -1
  77. package/src/interfaces/singly-linked-list.ts +0 -1
  78. package/src/interfaces/tree-multiset.ts +0 -7
  79. package/src/interfaces/undirected-graph.ts +0 -6
  80. package/src/types/data-structures/abstract-binary-tree.ts +0 -50
  81. package/src/types/data-structures/abstract-graph.ts +0 -11
  82. package/src/types/data-structures/avl-tree.ts +0 -5
  83. package/src/types/data-structures/binary-tree.ts +0 -5
  84. package/src/types/data-structures/bst.ts +0 -13
  85. package/src/types/data-structures/directed-graph.ts +0 -8
  86. package/src/types/data-structures/doubly-linked-list.ts +0 -1
  87. package/src/types/data-structures/hash.ts +0 -1
  88. package/src/types/data-structures/heap.ts +0 -5
  89. package/src/types/data-structures/index.ts +0 -16
  90. package/src/types/data-structures/map-graph.ts +0 -1
  91. package/src/types/data-structures/navigator.ts +0 -13
  92. package/src/types/data-structures/priority-queue.ts +0 -9
  93. package/src/types/data-structures/rb-tree.ts +0 -8
  94. package/src/types/data-structures/segment-tree.ts +0 -1
  95. package/src/types/data-structures/singly-linked-list.ts +0 -1
  96. package/src/types/data-structures/tree-multiset.ts +0 -6
  97. package/src/types/helpers.ts +0 -1
  98. package/src/types/index.ts +0 -3
  99. package/src/types/utils/index.ts +0 -2
  100. package/src/types/utils/utils.ts +0 -6
  101. package/src/types/utils/validate-type.ts +0 -35
  102. package/src/utils/index.ts +0 -1
  103. package/src/utils/utils.ts +0 -79
  104. package/test/integration/avl-tree.test.ts +0 -108
  105. package/test/integration/bst.test.ts +0 -380
  106. package/test/integration/heap.test.js +0 -16
  107. package/test/integration/index.html +0 -52
  108. package/test/unit/data-structures/binary-tree/avl-tree.test.ts +0 -108
  109. package/test/unit/data-structures/binary-tree/binary-tree.test.ts +0 -142
  110. package/test/unit/data-structures/binary-tree/bst.test.ts +0 -380
  111. package/test/unit/data-structures/binary-tree/overall.test.ts +0 -65
  112. package/test/unit/data-structures/binary-tree/rb-tree.test.ts +0 -43
  113. package/test/unit/data-structures/binary-tree/segment-tree.test.ts +0 -50
  114. package/test/unit/data-structures/binary-tree/tree-multiset.test.ts +0 -461
  115. package/test/unit/data-structures/graph/abstract-graph.test.ts +0 -5
  116. package/test/unit/data-structures/graph/directed-graph.test.ts +0 -519
  117. package/test/unit/data-structures/graph/index.ts +0 -2
  118. package/test/unit/data-structures/graph/map-graph.test.ts +0 -45
  119. package/test/unit/data-structures/graph/overall.test.ts +0 -49
  120. package/test/unit/data-structures/graph/undirected-graph.test.ts +0 -59
  121. package/test/unit/data-structures/hash/coordinate-map.test.ts +0 -54
  122. package/test/unit/data-structures/hash/coordinate-set.test.ts +0 -41
  123. package/test/unit/data-structures/hash/hash-map.test.ts +0 -104
  124. package/test/unit/data-structures/hash/hash-table.test.ts +0 -184
  125. package/test/unit/data-structures/heap/heap.test.ts +0 -55
  126. package/test/unit/data-structures/heap/max-heap.test.ts +0 -44
  127. package/test/unit/data-structures/heap/min-heap.test.ts +0 -82
  128. package/test/unit/data-structures/linked-list/doubly-linked-list.test.ts +0 -364
  129. package/test/unit/data-structures/linked-list/index.ts +0 -4
  130. package/test/unit/data-structures/linked-list/linked-list.test.ts +0 -35
  131. package/test/unit/data-structures/linked-list/singly-linked-list.test.ts +0 -451
  132. package/test/unit/data-structures/linked-list/skip-linked-list.test.ts +0 -13
  133. package/test/unit/data-structures/linked-list/skip-list.test.ts +0 -55
  134. package/test/unit/data-structures/matrix/matrix.test.ts +0 -54
  135. package/test/unit/data-structures/matrix/matrix2d.test.ts +0 -138
  136. package/test/unit/data-structures/matrix/navigator.test.ts +0 -79
  137. package/test/unit/data-structures/priority-queue/max-priority-queue.test.ts +0 -106
  138. package/test/unit/data-structures/priority-queue/min-priority-queue.test.ts +0 -105
  139. package/test/unit/data-structures/priority-queue/priority-queue.test.ts +0 -27
  140. package/test/unit/data-structures/queue/deque.test.ts +0 -130
  141. package/test/unit/data-structures/queue/queue.test.ts +0 -199
  142. package/test/unit/data-structures/stack/stack.test.ts +0 -67
  143. package/test/unit/data-structures/tree/tree.test.ts +0 -39
  144. package/test/unit/data-structures/trie/trie.test.ts +0 -95
  145. package/test/utils/index.ts +0 -2
  146. package/test/utils/magnitude.ts +0 -21
  147. package/test/utils/number.ts +0 -3
  148. package/tsconfig.json +0 -29
@@ -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,4 +0,0 @@
1
- export * from './data-structures';
2
- export * from './utils';
3
- export * from './interfaces';
4
- export * from './types';
@@ -1,189 +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 root(): N | null;
54
-
55
- get size(): number;
56
-
57
- swapLocation(srcNode: N, destNode: N): N;
58
-
59
- clear(): void;
60
-
61
- isEmpty(): boolean;
62
-
63
- add(id: BinaryTreeNodeId | N, val?: N['val']): N | null | undefined;
64
-
65
- addMany(idsOrNodes: (BinaryTreeNodeId | N | null)[], data?: N['val'][]): (N | null | undefined)[];
66
-
67
- fill(idsOrNodes: (BinaryTreeNodeId | N | null)[], data?: N[] | Array<N['val']>): boolean;
68
-
69
- remove(id: BinaryTreeNodeId, ignoreCount?: boolean): BinaryTreeDeletedResult<N>[];
70
-
71
- getDepth(node: N): number;
72
-
73
- getHeight(beginRoot?: N | null): number;
74
-
75
- getMinHeight(beginRoot?: N | null): number;
76
-
77
- isPerfectlyBalanced(beginRoot?: N | null): boolean;
78
-
79
- getNodes(nodeProperty: BinaryTreeNodeId | N, propertyName?: BinaryTreeNodePropertyName, onlyOne?: boolean): N[];
80
-
81
- has(nodeProperty: BinaryTreeNodeId | N, propertyName?: BinaryTreeNodePropertyName): boolean;
82
-
83
- get(nodeProperty: BinaryTreeNodeId | N, propertyName?: BinaryTreeNodePropertyName): N | null;
84
-
85
- getPathToRoot(node: N): N[];
86
-
87
- getLeftMost(): N | null;
88
-
89
- getLeftMost(node: N): N;
90
-
91
- getLeftMost(node?: N | null): N | null;
92
-
93
- getRightMost(): N | null;
94
-
95
- getRightMost(node: N): N;
96
-
97
- getRightMost(node?: N | null): N | null;
98
-
99
- isSubtreeBST(node: N | null): boolean;
100
-
101
- isBST(): boolean;
102
-
103
- getSubTreeSize(subTreeRoot: N | null | undefined): number;
104
-
105
- // --- start additional methods ---
106
-
107
- subTreeSum(subTreeRoot: N, propertyName?: BinaryTreeNodePropertyName): number;
108
-
109
- subTreeAdd(subTreeRoot: N, delta: number, propertyName?: BinaryTreeNodePropertyName): boolean;
110
-
111
- BFS(): BinaryTreeNodeId[];
112
-
113
- BFS(nodeOrPropertyName: 'id'): BinaryTreeNodeId[];
114
-
115
- BFS(nodeOrPropertyName: 'val'): N['val'][];
116
-
117
- BFS(nodeOrPropertyName: 'node'): N[];
118
-
119
- BFS(nodeOrPropertyName: 'count'): number[];
120
-
121
- BFS(nodeOrPropertyName?: NodeOrPropertyName): AbstractBinaryTreeNodeProperties<N>;
122
-
123
- DFS(): BinaryTreeNodeId[];
124
-
125
- DFS(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'id'): BinaryTreeNodeId[];
126
-
127
- DFS(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'val'): N[];
128
-
129
- DFS(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'node'): N[];
130
-
131
- DFS(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'count'): number[];
132
-
133
- DFS(pattern?: 'in' | 'pre' | 'post', nodeOrPropertyName?: NodeOrPropertyName): AbstractBinaryTreeNodeProperties<N>;
134
-
135
- DFSIterative(): BinaryTreeNodeId[];
136
-
137
- DFSIterative(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'id'): BinaryTreeNodeId[];
138
-
139
- DFSIterative(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'val'): N[];
140
-
141
- DFSIterative(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'node'): N[];
142
-
143
- DFSIterative(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'count'): number[];
144
-
145
- DFSIterative(
146
- pattern?: 'in' | 'pre' | 'post',
147
- nodeOrPropertyName?: NodeOrPropertyName
148
- ): AbstractBinaryTreeNodeProperties<N>;
149
-
150
- levelIterative(node: N | null): BinaryTreeNodeId[];
151
-
152
- levelIterative(node: N | null, nodeOrPropertyName?: 'id'): BinaryTreeNodeId[];
153
-
154
- levelIterative(node: N | null, nodeOrPropertyName?: 'val'): N['val'][];
155
-
156
- levelIterative(node: N | null, nodeOrPropertyName?: 'node'): N[];
157
-
158
- levelIterative(node: N | null, nodeOrPropertyName?: 'count'): number[];
159
-
160
- levelIterative(node: N | null, nodeOrPropertyName?: NodeOrPropertyName): AbstractBinaryTreeNodeProperties<N>;
161
-
162
- listLevels(node: N | null): BinaryTreeNodeId[][];
163
-
164
- listLevels(node: N | null, nodeOrPropertyName?: 'id'): BinaryTreeNodeId[][];
165
-
166
- listLevels(node: N | null, nodeOrPropertyName?: 'val'): N['val'][][];
167
-
168
- listLevels(node: N | null, nodeOrPropertyName?: 'node'): N[][];
169
-
170
- listLevels(node: N | null, nodeOrPropertyName?: 'count'): number[][];
171
-
172
- listLevels(node: N | null, nodeOrPropertyName?: NodeOrPropertyName): AbstractBinaryTreeNodeProperty<N>[][];
173
-
174
- getPredecessor(node: N): N;
175
-
176
- morris(): BinaryTreeNodeId[];
177
-
178
- morris(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'id'): BinaryTreeNodeId[];
179
-
180
- morris(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'val'): N[];
181
-
182
- morris(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'node'): N[];
183
-
184
- morris(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'count'): number[];
185
-
186
- morris(pattern?: 'in' | 'pre' | 'post', nodeOrPropertyName?: NodeOrPropertyName): AbstractBinaryTreeNodeProperties<N>;
187
-
188
- // --- end additional methods ---
189
- }
@@ -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): 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>;
@@ -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 {};
@@ -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,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,6 +0,0 @@
1
- import {VertexId} from '../types';
2
- import {IAbstractGraph} from './abstract-graph';
3
-
4
- export interface IUNDirectedGraph<V, E> extends IAbstractGraph<V, E> {
5
- removeEdgeBetween(v1: V | VertexId, v2: V | VertexId): E | null;
6
- }
@@ -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 & {};
@@ -1,5 +0,0 @@
1
- import {BinaryTreeNode} from '../../data-structures/binary-tree';
2
- import {AbstractBinaryTreeOptions} from './abstract-binary-tree';
3
-
4
- export type BinaryTreeNodeNested<T> = BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
5
- export type BinaryTreeOptions = AbstractBinaryTreeOptions & {}