data-structure-typed 1.36.1 → 1.36.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (207) hide show
  1. package/CHANGELOG.md +2 -1
  2. package/README.md +1 -1
  3. package/dist/data-structures/binary-tree/avl-tree.d.ts +3 -3
  4. package/dist/data-structures/binary-tree/avl-tree.js.map +1 -1
  5. package/dist/data-structures/binary-tree/binary-tree.d.ts +8 -8
  6. package/dist/data-structures/binary-tree/binary-tree.js +11 -13
  7. package/dist/data-structures/binary-tree/binary-tree.js.map +1 -1
  8. package/dist/data-structures/binary-tree/bst.d.ts +3 -3
  9. package/dist/data-structures/binary-tree/bst.js.map +1 -1
  10. package/dist/data-structures/binary-tree/index.d.ts +0 -5
  11. package/dist/data-structures/binary-tree/index.js +0 -5
  12. package/dist/data-structures/binary-tree/index.js.map +1 -1
  13. package/dist/data-structures/binary-tree/rb-tree.d.ts +3 -3
  14. package/dist/data-structures/binary-tree/rb-tree.js.map +1 -1
  15. package/dist/data-structures/binary-tree/tree-multiset.d.ts +3 -3
  16. package/dist/data-structures/binary-tree/tree-multiset.js.map +1 -1
  17. package/dist/data-structures/graph/abstract-graph.d.ts +2 -2
  18. package/dist/data-structures/graph/directed-graph.d.ts +2 -2
  19. package/dist/data-structures/graph/map-graph.d.ts +1 -1
  20. package/dist/data-structures/graph/map-graph.js +1 -1
  21. package/dist/data-structures/graph/undirected-graph.d.ts +2 -2
  22. package/dist/data-structures/hash/index.d.ts +0 -1
  23. package/dist/data-structures/hash/index.js +0 -1
  24. package/dist/data-structures/hash/index.js.map +1 -1
  25. package/dist/data-structures/heap/heap.d.ts +4 -4
  26. package/dist/data-structures/heap/heap.js.map +1 -1
  27. package/dist/data-structures/heap/max-heap.d.ts +2 -2
  28. package/dist/data-structures/heap/max-heap.js.map +1 -1
  29. package/dist/data-structures/heap/min-heap.d.ts +2 -2
  30. package/dist/data-structures/heap/min-heap.js.map +1 -1
  31. package/dist/data-structures/priority-queue/max-priority-queue.d.ts +2 -2
  32. package/dist/data-structures/priority-queue/max-priority-queue.js.map +1 -1
  33. package/dist/data-structures/priority-queue/min-priority-queue.d.ts +2 -2
  34. package/dist/data-structures/priority-queue/min-priority-queue.js.map +1 -1
  35. package/dist/data-structures/priority-queue/priority-queue.d.ts +2 -2
  36. package/dist/data-structures/priority-queue/priority-queue.js.map +1 -1
  37. package/dist/interfaces/binary-tree.d.ts +5 -4
  38. package/dist/interfaces/{abstract-graph.d.ts → graph.d.ts} +1 -1
  39. package/dist/interfaces/{bst.js → graph.js} +1 -1
  40. package/dist/interfaces/graph.js.map +1 -0
  41. package/dist/interfaces/index.d.ts +1 -8
  42. package/dist/interfaces/index.js +1 -8
  43. package/dist/interfaces/index.js.map +1 -1
  44. package/dist/types/data-structures/abstract-graph.d.ts +0 -1
  45. package/dist/types/data-structures/binary-tree.d.ts +30 -2
  46. package/dist/types/data-structures/binary-tree.js +22 -0
  47. package/dist/types/data-structures/binary-tree.js.map +1 -1
  48. package/dist/types/data-structures/bst.d.ts +1 -2
  49. package/dist/types/data-structures/heap.d.ts +2 -1
  50. package/dist/types/data-structures/index.d.ts +0 -2
  51. package/dist/types/data-structures/index.js +0 -2
  52. package/dist/types/data-structures/index.js.map +1 -1
  53. package/lib/data-structures/binary-tree/avl-tree.d.ts +3 -3
  54. package/lib/data-structures/binary-tree/binary-tree.d.ts +8 -8
  55. package/lib/data-structures/binary-tree/binary-tree.js +11 -13
  56. package/lib/data-structures/binary-tree/bst.d.ts +3 -3
  57. package/lib/data-structures/binary-tree/index.d.ts +0 -5
  58. package/lib/data-structures/binary-tree/index.js +0 -5
  59. package/lib/data-structures/binary-tree/rb-tree.d.ts +3 -3
  60. package/lib/data-structures/binary-tree/tree-multiset.d.ts +3 -3
  61. package/lib/data-structures/graph/abstract-graph.d.ts +2 -2
  62. package/lib/data-structures/graph/directed-graph.d.ts +2 -2
  63. package/lib/data-structures/graph/map-graph.d.ts +1 -1
  64. package/lib/data-structures/graph/map-graph.js +1 -1
  65. package/lib/data-structures/graph/undirected-graph.d.ts +2 -2
  66. package/lib/data-structures/hash/index.d.ts +0 -1
  67. package/lib/data-structures/hash/index.js +0 -1
  68. package/lib/data-structures/heap/heap.d.ts +4 -4
  69. package/lib/data-structures/heap/max-heap.d.ts +2 -2
  70. package/lib/data-structures/heap/min-heap.d.ts +2 -2
  71. package/lib/data-structures/priority-queue/max-priority-queue.d.ts +2 -2
  72. package/lib/data-structures/priority-queue/min-priority-queue.d.ts +2 -2
  73. package/lib/data-structures/priority-queue/priority-queue.d.ts +2 -2
  74. package/lib/interfaces/binary-tree.d.ts +5 -4
  75. package/lib/interfaces/{abstract-graph.d.ts → graph.d.ts} +1 -1
  76. package/lib/interfaces/index.d.ts +1 -8
  77. package/lib/interfaces/index.js +1 -8
  78. package/lib/types/data-structures/abstract-graph.d.ts +0 -1
  79. package/lib/types/data-structures/binary-tree.d.ts +30 -2
  80. package/lib/types/data-structures/binary-tree.js +21 -1
  81. package/lib/types/data-structures/bst.d.ts +1 -2
  82. package/lib/types/data-structures/heap.d.ts +2 -1
  83. package/lib/types/data-structures/index.d.ts +0 -2
  84. package/lib/types/data-structures/index.js +0 -2
  85. package/package.json +5 -5
  86. package/src/data-structures/binary-tree/avl-tree.ts +6 -6
  87. package/src/data-structures/binary-tree/binary-tree.ts +29 -39
  88. package/src/data-structures/binary-tree/bst.ts +3 -6
  89. package/src/data-structures/binary-tree/index.ts +0 -5
  90. package/src/data-structures/binary-tree/rb-tree.ts +6 -6
  91. package/src/data-structures/binary-tree/tree-multiset.ts +6 -6
  92. package/src/data-structures/graph/abstract-graph.ts +2 -2
  93. package/src/data-structures/graph/directed-graph.ts +2 -2
  94. package/src/data-structures/graph/map-graph.ts +1 -1
  95. package/src/data-structures/graph/undirected-graph.ts +2 -2
  96. package/src/data-structures/hash/index.ts +0 -1
  97. package/src/data-structures/heap/heap.ts +5 -5
  98. package/src/data-structures/heap/max-heap.ts +2 -2
  99. package/src/data-structures/heap/min-heap.ts +2 -2
  100. package/src/data-structures/priority-queue/max-priority-queue.ts +2 -2
  101. package/src/data-structures/priority-queue/min-priority-queue.ts +2 -2
  102. package/src/data-structures/priority-queue/priority-queue.ts +2 -2
  103. package/src/interfaces/binary-tree.ts +7 -4
  104. package/src/interfaces/{abstract-graph.ts → graph.ts} +1 -1
  105. package/src/interfaces/index.ts +1 -8
  106. package/src/types/data-structures/abstract-graph.ts +1 -1
  107. package/src/types/data-structures/binary-tree.ts +42 -2
  108. package/src/types/data-structures/bst.ts +2 -2
  109. package/src/types/data-structures/heap.ts +3 -1
  110. package/src/types/data-structures/index.ts +0 -2
  111. package/src/types/data-structures/navigator.ts +1 -0
  112. package/test/unit/data-structures/heap/max-heap.test.ts +2 -2
  113. package/test/unit/data-structures/heap/min-heap.test.ts +2 -2
  114. package/umd/bundle.min.js +1 -1
  115. package/umd/bundle.min.js.map +1 -1
  116. package/dist/data-structures/binary-tree/aa-tree.d.ts +0 -2
  117. package/dist/data-structures/binary-tree/aa-tree.js +0 -7
  118. package/dist/data-structures/binary-tree/aa-tree.js.map +0 -1
  119. package/dist/data-structures/binary-tree/abstract-binary-tree.d.ts +0 -21
  120. package/dist/data-structures/binary-tree/abstract-binary-tree.js +0 -25
  121. package/dist/data-structures/binary-tree/abstract-binary-tree.js.map +0 -1
  122. package/dist/data-structures/binary-tree/b-tree.d.ts +0 -2
  123. package/dist/data-structures/binary-tree/b-tree.js +0 -7
  124. package/dist/data-structures/binary-tree/b-tree.js.map +0 -1
  125. package/dist/data-structures/binary-tree/splay-tree.d.ts +0 -2
  126. package/dist/data-structures/binary-tree/splay-tree.js +0 -7
  127. package/dist/data-structures/binary-tree/splay-tree.js.map +0 -1
  128. package/dist/data-structures/binary-tree/two-three-tree.d.ts +0 -2
  129. package/dist/data-structures/binary-tree/two-three-tree.js +0 -7
  130. package/dist/data-structures/binary-tree/two-three-tree.js.map +0 -1
  131. package/dist/data-structures/hash/pair.d.ts +0 -2
  132. package/dist/data-structures/hash/pair.js +0 -7
  133. package/dist/data-structures/hash/pair.js.map +0 -1
  134. package/dist/interfaces/abstract-binary-tree.d.ts +0 -7
  135. package/dist/interfaces/abstract-binary-tree.js +0 -3
  136. package/dist/interfaces/abstract-binary-tree.js.map +0 -1
  137. package/dist/interfaces/abstract-graph.js +0 -3
  138. package/dist/interfaces/abstract-graph.js.map +0 -1
  139. package/dist/interfaces/avl-tree.d.ts +0 -7
  140. package/dist/interfaces/avl-tree.js +0 -3
  141. package/dist/interfaces/avl-tree.js.map +0 -1
  142. package/dist/interfaces/bst.d.ts +0 -6
  143. package/dist/interfaces/bst.js.map +0 -1
  144. package/dist/interfaces/directed-graph.d.ts +0 -3
  145. package/dist/interfaces/directed-graph.js +0 -3
  146. package/dist/interfaces/directed-graph.js.map +0 -1
  147. package/dist/interfaces/rb-tree.d.ts +0 -6
  148. package/dist/interfaces/rb-tree.js +0 -3
  149. package/dist/interfaces/rb-tree.js.map +0 -1
  150. package/dist/interfaces/tree-multiset.d.ts +0 -6
  151. package/dist/interfaces/tree-multiset.js +0 -3
  152. package/dist/interfaces/tree-multiset.js.map +0 -1
  153. package/dist/interfaces/undirected-graph.d.ts +0 -3
  154. package/dist/interfaces/undirected-graph.js +0 -3
  155. package/dist/interfaces/undirected-graph.js.map +0 -1
  156. package/dist/types/data-structures/abstract-binary-tree.d.ts +0 -32
  157. package/dist/types/data-structures/abstract-binary-tree.js +0 -25
  158. package/dist/types/data-structures/abstract-binary-tree.js.map +0 -1
  159. package/dist/types/data-structures/priority-queue.d.ts +0 -7
  160. package/dist/types/data-structures/priority-queue.js +0 -3
  161. package/dist/types/data-structures/priority-queue.js.map +0 -1
  162. package/lib/data-structures/binary-tree/aa-tree.d.ts +0 -2
  163. package/lib/data-structures/binary-tree/aa-tree.js +0 -2
  164. package/lib/data-structures/binary-tree/abstract-binary-tree.d.ts +0 -21
  165. package/lib/data-structures/binary-tree/abstract-binary-tree.js +0 -19
  166. package/lib/data-structures/binary-tree/b-tree.d.ts +0 -2
  167. package/lib/data-structures/binary-tree/b-tree.js +0 -2
  168. package/lib/data-structures/binary-tree/splay-tree.d.ts +0 -2
  169. package/lib/data-structures/binary-tree/splay-tree.js +0 -2
  170. package/lib/data-structures/binary-tree/two-three-tree.d.ts +0 -2
  171. package/lib/data-structures/binary-tree/two-three-tree.js +0 -2
  172. package/lib/data-structures/hash/pair.d.ts +0 -2
  173. package/lib/data-structures/hash/pair.js +0 -2
  174. package/lib/interfaces/abstract-binary-tree.d.ts +0 -7
  175. package/lib/interfaces/abstract-graph.js +0 -1
  176. package/lib/interfaces/avl-tree.d.ts +0 -7
  177. package/lib/interfaces/avl-tree.js +0 -1
  178. package/lib/interfaces/bst.d.ts +0 -6
  179. package/lib/interfaces/bst.js +0 -1
  180. package/lib/interfaces/directed-graph.d.ts +0 -3
  181. package/lib/interfaces/directed-graph.js +0 -1
  182. package/lib/interfaces/rb-tree.d.ts +0 -6
  183. package/lib/interfaces/rb-tree.js +0 -1
  184. package/lib/interfaces/tree-multiset.d.ts +0 -6
  185. package/lib/interfaces/tree-multiset.js +0 -1
  186. package/lib/interfaces/undirected-graph.d.ts +0 -3
  187. package/lib/interfaces/undirected-graph.js +0 -1
  188. package/lib/types/data-structures/abstract-binary-tree.d.ts +0 -32
  189. package/lib/types/data-structures/abstract-binary-tree.js +0 -21
  190. package/lib/types/data-structures/priority-queue.d.ts +0 -7
  191. package/lib/types/data-structures/priority-queue.js +0 -1
  192. package/src/data-structures/binary-tree/aa-tree.ts +0 -1
  193. package/src/data-structures/binary-tree/abstract-binary-tree.ts +0 -33
  194. package/src/data-structures/binary-tree/b-tree.ts +0 -1
  195. package/src/data-structures/binary-tree/splay-tree.ts +0 -1
  196. package/src/data-structures/binary-tree/two-three-tree.ts +0 -1
  197. package/src/data-structures/hash/pair.ts +0 -1
  198. package/src/interfaces/abstract-binary-tree.ts +0 -8
  199. package/src/interfaces/avl-tree.ts +0 -8
  200. package/src/interfaces/bst.ts +0 -6
  201. package/src/interfaces/directed-graph.ts +0 -3
  202. package/src/interfaces/rb-tree.ts +0 -6
  203. package/src/interfaces/tree-multiset.ts +0 -7
  204. package/src/interfaces/undirected-graph.ts +0 -3
  205. package/src/types/data-structures/abstract-binary-tree.ts +0 -49
  206. package/src/types/data-structures/priority-queue.ts +0 -9
  207. /package/lib/interfaces/{abstract-binary-tree.js → graph.js} +0 -0
@@ -6,12 +6,15 @@
6
6
  * @license MIT License
7
7
  */
8
8
 
9
- import type {BinaryTreeNodeKey, BinaryTreeNodeNested, BinaryTreeOptions} from '../../types';
10
- import {AbstractBinaryTree, AbstractBinaryTreeNode} from './abstract-binary-tree';
11
- import {IBinaryTree, IBinaryTreeNode} from '../../interfaces';
9
+ import type {
10
+ BinaryTreeNodeKey,
11
+ BinaryTreeNodeNested,
12
+ BinaryTreeNodeProperties,
13
+ BinaryTreeNodeProperty,
14
+ BinaryTreeOptions
15
+ } from '../../types';
16
+ import {IBinaryTree} from '../../interfaces';
12
17
  import {
13
- AbstractBinaryTreeNodeProperties,
14
- AbstractBinaryTreeNodeProperty,
15
18
  BinaryTreeDeletedResult,
16
19
  BinaryTreeNodePropertyName,
17
20
  DFSOrderPattern,
@@ -21,10 +24,7 @@ import {
21
24
  } from '../../types';
22
25
  import {trampoline} from '../../utils';
23
26
 
24
- export class BinaryTreeNode<V = any, FAMILY extends BinaryTreeNode<V, FAMILY> = BinaryTreeNodeNested<V>>
25
- extends AbstractBinaryTreeNode<V, FAMILY>
26
- implements IBinaryTreeNode<V, FAMILY>
27
- {
27
+ export class BinaryTreeNode<V = any, FAMILY extends BinaryTreeNode<V, FAMILY> = BinaryTreeNodeNested<V>> {
28
28
  /**
29
29
  * The constructor function initializes a BinaryTreeNode object with a key and an optional value.
30
30
  * @param {BinaryTreeNodeKey} key - The `key` parameter is of type `BinaryTreeNodeKey` and represents the unique identifier
@@ -33,12 +33,14 @@ export class BinaryTreeNode<V = any, FAMILY extends BinaryTreeNode<V, FAMILY> =
33
33
  * stored in the binary tree node. If no value is provided, it will be set to undefined.
34
34
  */
35
35
  constructor(key: BinaryTreeNodeKey, val?: V) {
36
- super(val);
37
36
  this.key = key;
37
+ this.val = val;
38
38
  }
39
39
 
40
40
  key: BinaryTreeNodeKey;
41
41
 
42
+ val: V | undefined;
43
+
42
44
  private _left: FAMILY | null | undefined;
43
45
 
44
46
  get left(): FAMILY | null | undefined {
@@ -99,10 +101,7 @@ export class BinaryTreeNode<V = any, FAMILY extends BinaryTreeNode<V, FAMILY> =
99
101
  }
100
102
  }
101
103
 
102
- export class BinaryTree<N extends BinaryTreeNode<N['val'], N> = BinaryTreeNode>
103
- extends AbstractBinaryTree<N>
104
- implements IBinaryTree<N>
105
- {
104
+ export class BinaryTree<N extends BinaryTreeNode<N['val'], N> = BinaryTreeNode> implements IBinaryTree<N> {
106
105
  /**
107
106
  * This is a constructor function for a binary tree class that takes an optional options parameter.
108
107
  * @param {BinaryTreeOptions} [options] - The `options` parameter is an optional object that can be passed to the
@@ -110,7 +109,6 @@ export class BinaryTree<N extends BinaryTreeNode<N['val'], N> = BinaryTreeNode>
110
109
  * different configuration options.
111
110
  */
112
111
  constructor(options?: BinaryTreeOptions) {
113
- super();
114
112
  if (options !== undefined) {
115
113
  const {loopType = LoopType.ITERATIVE} = options;
116
114
  this._loopType = loopType;
@@ -228,7 +226,7 @@ export class BinaryTree<N extends BinaryTreeNode<N['val'], N> = BinaryTreeNode>
228
226
  needInsert = null;
229
227
  } else if (typeof keyOrNode === 'number') {
230
228
  needInsert = this.createNode(keyOrNode, val);
231
- } else if (keyOrNode instanceof AbstractBinaryTreeNode) {
229
+ } else if (keyOrNode instanceof BinaryTreeNode) {
232
230
  needInsert = keyOrNode;
233
231
  } else {
234
232
  return;
@@ -271,7 +269,7 @@ export class BinaryTree<N extends BinaryTreeNode<N['val'], N> = BinaryTreeNode>
271
269
 
272
270
  for (let i = 0; i < keysOrNodes.length; i++) {
273
271
  const keyOrNode = keysOrNodes[i];
274
- if (keyOrNode instanceof AbstractBinaryTreeNode) {
272
+ if (keyOrNode instanceof BinaryTreeNode) {
275
273
  inserted.push(this.add(keyOrNode.key, keyOrNode.val));
276
274
  continue;
277
275
  }
@@ -894,9 +892,9 @@ export class BinaryTree<N extends BinaryTreeNode<N['val'], N> = BinaryTreeNode>
894
892
  * @param {NodeOrPropertyName} [nodeOrPropertyName] - An optional parameter that represents either a node or a property name.
895
893
  * If a node is provided, the bfs algorithm will be performed starting from that node.
896
894
  * If a property name is provided, the bfs algorithm will be performed starting from the root node, accumulating the specified property.
897
- * @returns An instance of the `AbstractBinaryTreeNodeProperties` class with generic type `N`.
895
+ * @returns An instance of the `BinaryTreeNodeProperties` class with generic type `N`.
898
896
  */
899
- bfs(nodeOrPropertyName: NodeOrPropertyName = 'key'): AbstractBinaryTreeNodeProperties<N> {
897
+ bfs(nodeOrPropertyName: NodeOrPropertyName = 'key'): BinaryTreeNodeProperties<N> {
900
898
  this._clearResults();
901
899
  const queue: Array<N | null | undefined> = [this.root];
902
900
 
@@ -954,12 +952,9 @@ export class BinaryTree<N extends BinaryTreeNode<N['val'], N> = BinaryTreeNode>
954
952
  * each node based on the specified pattern and property name.
955
953
  * @param {'in' | 'pre' | 'post'} [pattern] - The traversal pattern: 'in' (in-order), 'pre' (pre-order), or 'post' (post-order).
956
954
  * @param {NodeOrPropertyName} [nodeOrPropertyName] - The name of a property of the nodes in the binary tree. This property will be used to accumulate values during the depth-first search traversal. If no `nodeOrPropertyName` is provided, the default value is `'key'`.
957
- * @returns an instance of the AbstractBinaryTreeNodeProperties class, which contains the accumulated properties of the binary tree nodes based on the specified pattern and node or property name.
955
+ * @returns an instance of the BinaryTreeNodeProperties class, which contains the accumulated properties of the binary tree nodes based on the specified pattern and node or property name.
958
956
  */
959
- dfs(
960
- pattern: DFSOrderPattern = 'in',
961
- nodeOrPropertyName: NodeOrPropertyName = 'key'
962
- ): AbstractBinaryTreeNodeProperties<N> {
957
+ dfs(pattern: DFSOrderPattern = 'in', nodeOrPropertyName: NodeOrPropertyName = 'key'): BinaryTreeNodeProperties<N> {
963
958
  this._clearResults();
964
959
  const _traverse = (node: N) => {
965
960
  switch (pattern) {
@@ -1029,12 +1024,12 @@ export class BinaryTree<N extends BinaryTreeNode<N['val'], N> = BinaryTreeNode>
1029
1024
  * specify the traversal pattern and the property name to accumulate results by.
1030
1025
  * @param {'in' | 'pre' | 'post'} [pattern] - The traversal pattern: 'in' (in-order), 'pre' (pre-order), or 'post' (post-order).
1031
1026
  * @param {NodeOrPropertyName} [nodeOrPropertyName] - The name of a property of the nodes in the binary tree. This property will be used to accumulate values during the depth-first search traversal. By default, it is set to `'key'`.
1032
- * @returns An object of type AbstractBinaryTreeNodeProperties<N>.
1027
+ * @returns An object of type BinaryTreeNodeProperties<N>.
1033
1028
  */
1034
1029
  dfsIterative(
1035
1030
  pattern: DFSOrderPattern = 'in',
1036
1031
  nodeOrPropertyName: NodeOrPropertyName = 'key'
1037
- ): AbstractBinaryTreeNodeProperties<N> {
1032
+ ): BinaryTreeNodeProperties<N> {
1038
1033
  this._clearResults();
1039
1034
  if (!this.root) return this._getResultByPropertyName(nodeOrPropertyName);
1040
1035
  // 0: visit, 1: print
@@ -1121,12 +1116,12 @@ export class BinaryTree<N extends BinaryTreeNode<N['val'], N> = BinaryTreeNode>
1121
1116
  * can be either a `BinaryTreeNode` property name or the string `'key'`. If a property name is provided, the function
1122
1117
  * will accumulate results based on that property. If no property name is provided, the function will default to
1123
1118
  * accumulating results based on the 'key' property.
1124
- * @returns An object of type `AbstractBinaryTreeNodeProperties<N>`.
1119
+ * @returns An object of type `BinaryTreeNodeProperties<N>`.
1125
1120
  */
1126
1121
  levelIterative(
1127
1122
  node: N | null = this.root,
1128
1123
  nodeOrPropertyName: NodeOrPropertyName = 'key'
1129
- ): AbstractBinaryTreeNodeProperties<N> {
1124
+ ): BinaryTreeNodeProperties<N> {
1130
1125
  if (!node) return [];
1131
1126
 
1132
1127
  this._clearResults();
@@ -1194,10 +1189,10 @@ export class BinaryTree<N extends BinaryTreeNode<N['val'], N> = BinaryTreeNode>
1194
1189
  listLevels(
1195
1190
  node: N | null = this.root,
1196
1191
  nodeOrPropertyName: NodeOrPropertyName = 'key'
1197
- ): AbstractBinaryTreeNodeProperty<N>[][] {
1192
+ ): BinaryTreeNodeProperty<N>[][] {
1198
1193
  if (!node) return [];
1199
1194
 
1200
- const levelsNodes: AbstractBinaryTreeNodeProperty<N>[][] = [];
1195
+ const levelsNodes: BinaryTreeNodeProperty<N>[][] = [];
1201
1196
 
1202
1197
  const collectByProperty = (node: N, level: number) => {
1203
1198
  switch (nodeOrPropertyName) {
@@ -1307,12 +1302,9 @@ export class BinaryTree<N extends BinaryTreeNode<N['val'], N> = BinaryTreeNode>
1307
1302
  * The `morris` function performs an in-order, pre-order, or post-order traversal on a binary tree using the Morris traversal algorithm.
1308
1303
  * @param {'in' | 'pre' | 'post'} [pattern] - The traversal pattern: 'in' (in-order), 'pre' (pre-order), or 'post' (post-order).
1309
1304
  * @param {NodeOrPropertyName} [nodeOrPropertyName] - The property name of the nodes to retrieve or perform operations on during the traversal. It can be any valid property name of the nodes in the binary tree. If not provided, it defaults to 'key'.
1310
- * @returns An array of AbstractBinaryTreeNodeProperties<N> objects.
1305
+ * @returns An array of BinaryTreeNodeProperties<N> objects.
1311
1306
  */
1312
- morris(
1313
- pattern: DFSOrderPattern = 'in',
1314
- nodeOrPropertyName: NodeOrPropertyName = 'key'
1315
- ): AbstractBinaryTreeNodeProperties<N> {
1307
+ morris(pattern: DFSOrderPattern = 'in', nodeOrPropertyName: NodeOrPropertyName = 'key'): BinaryTreeNodeProperties<N> {
1316
1308
  if (this.root === null) return [];
1317
1309
 
1318
1310
  this._clearResults();
@@ -1545,11 +1537,9 @@ export class BinaryTree<N extends BinaryTreeNode<N['val'], N> = BinaryTreeNode>
1545
1537
  * name.
1546
1538
  * @param {NodeOrPropertyName} [nodeOrPropertyName] - The parameter `nodeOrPropertyName` is an optional parameter that
1547
1539
  * can accept either a `NodeOrPropertyName` type or be undefined.
1548
- * @returns The method `_getResultByPropertyName` returns an instance of `AbstractBinaryTreeNodeProperties<N>`.
1540
+ * @returns The method `_getResultByPropertyName` returns an instance of `BinaryTreeNodeProperties<N>`.
1549
1541
  */
1550
- protected _getResultByPropertyName(
1551
- nodeOrPropertyName: NodeOrPropertyName = 'key'
1552
- ): AbstractBinaryTreeNodeProperties<N> {
1542
+ protected _getResultByPropertyName(nodeOrPropertyName: NodeOrPropertyName = 'key'): BinaryTreeNodeProperties<N> {
1553
1543
  switch (nodeOrPropertyName) {
1554
1544
  case 'key':
1555
1545
  return this.visitedKey;
@@ -14,18 +14,15 @@ import type {
14
14
  } from '../../types';
15
15
  import {CP, LoopType} from '../../types';
16
16
  import {BinaryTree, BinaryTreeNode} from './binary-tree';
17
- import {IBST, IBSTNode} from '../../interfaces';
17
+ import {IBinaryTree} from '../../interfaces';
18
18
 
19
- export class BSTNode<V = any, FAMILY extends BSTNode<V, FAMILY> = BSTNodeNested<V>>
20
- extends BinaryTreeNode<V, FAMILY>
21
- implements IBSTNode<V, FAMILY>
22
- {
19
+ export class BSTNode<V = any, FAMILY extends BSTNode<V, FAMILY> = BSTNodeNested<V>> extends BinaryTreeNode<V, FAMILY> {
23
20
  constructor(key: BinaryTreeNodeKey, val?: V) {
24
21
  super(key, val);
25
22
  }
26
23
  }
27
24
 
28
- export class BST<N extends BSTNode<N['val'], N> = BSTNode> extends BinaryTree<N> implements IBST<N> {
25
+ export class BST<N extends BSTNode<N['val'], N> = BSTNode> extends BinaryTree<N> implements IBinaryTree<N> {
29
26
  /**
30
27
  * The constructor function initializes a binary search tree object with an optional comparator function.
31
28
  * @param {BSTOptions} [options] - An optional object that contains configuration options for the binary search tree.
@@ -1,12 +1,7 @@
1
- export * from './abstract-binary-tree';
2
1
  export * from './binary-tree';
3
2
  export * from './bst';
4
3
  export * from './binary-indexed-tree';
5
4
  export * from './segment-tree';
6
5
  export * from './avl-tree';
7
- export * from './b-tree';
8
6
  export * from './rb-tree';
9
- export * from './splay-tree';
10
- export * from './aa-tree';
11
7
  export * from './tree-multiset';
12
- export * from './two-three-tree';
@@ -1,11 +1,11 @@
1
1
  import {BinaryTreeNodeKey, RBColor, RBTreeNodeNested, RBTreeOptions} from '../../types';
2
- import {IRBTree, IRBTreeNode} from '../../interfaces';
2
+ import {IBinaryTree} from '../../interfaces';
3
3
  import {BST, BSTNode} from './bst';
4
4
 
5
- export class RBTreeNode<V = any, FAMILY extends RBTreeNode<V, FAMILY> = RBTreeNodeNested<V>>
6
- extends BSTNode<V, FAMILY>
7
- implements IRBTreeNode<V, FAMILY>
8
- {
5
+ export class RBTreeNode<V = any, FAMILY extends RBTreeNode<V, FAMILY> = RBTreeNodeNested<V>> extends BSTNode<
6
+ V,
7
+ FAMILY
8
+ > {
9
9
  private _color: RBColor;
10
10
 
11
11
  constructor(key: BinaryTreeNodeKey, val?: V) {
@@ -22,7 +22,7 @@ export class RBTreeNode<V = any, FAMILY extends RBTreeNode<V, FAMILY> = RBTreeNo
22
22
  }
23
23
  }
24
24
 
25
- export class RBTree<N extends RBTreeNode<N['val'], N> = RBTreeNode> extends BST<N> implements IRBTree<N> {
25
+ export class RBTree<N extends RBTreeNode<N['val'], N> = RBTreeNode> extends BST<N> implements IBinaryTree<N> {
26
26
  constructor(options?: RBTreeOptions) {
27
27
  super(options);
28
28
  }
@@ -7,13 +7,13 @@
7
7
  */
8
8
  import type {BinaryTreeNodeKey, TreeMultisetNodeNested, TreeMultisetOptions} from '../../types';
9
9
  import {BinaryTreeDeletedResult, CP, DFSOrderPattern, FamilyPosition, LoopType} from '../../types';
10
- import {ITreeMultiset, ITreeMultisetNode} from '../../interfaces';
10
+ import {IBinaryTree} from '../../interfaces';
11
11
  import {AVLTree, AVLTreeNode} from './avl-tree';
12
12
 
13
- export class TreeMultisetNode<V = any, FAMILY extends TreeMultisetNode<V, FAMILY> = TreeMultisetNodeNested<V>>
14
- extends AVLTreeNode<V, FAMILY>
15
- implements ITreeMultisetNode<V, FAMILY>
16
- {
13
+ export class TreeMultisetNode<
14
+ V = any,
15
+ FAMILY extends TreeMultisetNode<V, FAMILY> = TreeMultisetNodeNested<V>
16
+ > extends AVLTreeNode<V, FAMILY> {
17
17
  /**
18
18
  * The constructor function initializes a BinaryTreeNode object with a key, value, and count.
19
19
  * @param {BinaryTreeNodeKey} key - The `key` parameter is of type `BinaryTreeNodeKey` and represents the unique identifier
@@ -37,7 +37,7 @@ export class TreeMultisetNode<V = any, FAMILY extends TreeMultisetNode<V, FAMILY
37
37
  */
38
38
  export class TreeMultiset<N extends TreeMultisetNode<N['val'], N> = TreeMultisetNode>
39
39
  extends AVLTree<N>
40
- implements ITreeMultiset<N>
40
+ implements IBinaryTree<N>
41
41
  {
42
42
  /**
43
43
  * The constructor function for a TreeMultiset class in TypeScript, which extends another class and sets an option to
@@ -8,7 +8,7 @@
8
8
  import {arrayRemove, uuidV4} from '../../utils';
9
9
  import {PriorityQueue} from '../priority-queue';
10
10
  import type {DijkstraResult, VertexKey} from '../../types';
11
- import {IAbstractGraph} from '../../interfaces';
11
+ import {IGraph} from '../../interfaces';
12
12
 
13
13
  export abstract class AbstractVertex<V = any> {
14
14
  /**
@@ -104,7 +104,7 @@ export abstract class AbstractEdge<V = any> {
104
104
  export abstract class AbstractGraph<
105
105
  V extends AbstractVertex<any> = AbstractVertex<any>,
106
106
  E extends AbstractEdge<any> = AbstractEdge<any>
107
- > implements IAbstractGraph<V, E>
107
+ > implements IGraph<V, E>
108
108
  {
109
109
  private _vertices: Map<VertexKey, V> = new Map<VertexKey, V>();
110
110
 
@@ -8,7 +8,7 @@
8
8
  import {arrayRemove} from '../../utils';
9
9
  import {AbstractEdge, AbstractGraph, AbstractVertex} from './abstract-graph';
10
10
  import type {TopologicalStatus, VertexKey} from '../../types';
11
- import {IDirectedGraph} from '../../interfaces';
11
+ import {IGraph} from '../../interfaces';
12
12
 
13
13
  export class DirectedVertex<V = any> extends AbstractVertex<V> {
14
14
  /**
@@ -64,7 +64,7 @@ export class DirectedEdge<V = any> extends AbstractEdge<V> {
64
64
 
65
65
  export class DirectedGraph<V extends DirectedVertex<any> = DirectedVertex, E extends DirectedEdge<any> = DirectedEdge>
66
66
  extends AbstractGraph<V, E>
67
- implements IDirectedGraph<V, E>
67
+ implements IGraph<V, E>
68
68
  {
69
69
  /**
70
70
  * The constructor function initializes an instance of a class.
@@ -126,7 +126,7 @@ export class MapGraph<V extends MapVertex<V['val']> = MapVertex, E extends MapEd
126
126
  * If the weight is not provided, it can be set to a default value or left undefined.
127
127
  * @param [val] - The `val` parameter is an optional value that can be assigned to the edge. It can be of any type,
128
128
  * depending on the specific implementation of the `MapEdge` class.
129
- * @returns a new instance of the `MapEdge` class, casted as type `E`.
129
+ * @returns a new instance of the `MapEdge` class, cast as type `E`.
130
130
  */
131
131
  override createEdge(src: VertexKey, dest: VertexKey, weight?: number, val?: E['val']): E {
132
132
  return new MapEdge(src, dest, weight, val) as E;
@@ -8,7 +8,7 @@
8
8
  import {arrayRemove} from '../../utils';
9
9
  import {AbstractEdge, AbstractGraph, AbstractVertex} from './abstract-graph';
10
10
  import type {VertexKey} from '../../types';
11
- import {IUNDirectedGraph} from '../../interfaces';
11
+ import {IGraph} from '../../interfaces';
12
12
 
13
13
  export class UndirectedVertex<V = any> extends AbstractVertex<V> {
14
14
  /**
@@ -55,7 +55,7 @@ export class UndirectedGraph<
55
55
  E extends UndirectedEdge<any> = UndirectedEdge
56
56
  >
57
57
  extends AbstractGraph<V, E>
58
- implements IUNDirectedGraph<V, E>
58
+ implements IGraph<V, E>
59
59
  {
60
60
  /**
61
61
  * The constructor initializes a new Map object to store edges.
@@ -1,7 +1,6 @@
1
1
  export * from './hash-table';
2
2
  export * from './coordinate-map';
3
3
  export * from './coordinate-set';
4
- export * from './pair';
5
4
  export * from './tree-map';
6
5
  export * from './tree-set';
7
6
  export * from './hash-map';
@@ -5,13 +5,13 @@
5
5
  * @license MIT License
6
6
  */
7
7
 
8
- import type {CompareFunction} from '../../types';
8
+ import type {HeapComparator, HeapDFSOrderPattern} from '../../types';
9
9
 
10
10
  export class Heap<E> {
11
11
  protected nodes: E[] = [];
12
- private readonly comparator: CompareFunction<E>;
12
+ private readonly comparator: HeapComparator<E>;
13
13
 
14
- constructor(comparator: CompareFunction<E>) {
14
+ constructor(comparator: HeapComparator<E>) {
15
15
  this.comparator = comparator;
16
16
  }
17
17
 
@@ -158,7 +158,7 @@ export class Heap<E> {
158
158
  * @param order - Traversal order parameter: 'in' (in-order), 'pre' (pre-order) or 'post' (post-order).
159
159
  * @returns An array containing elements traversed in the specified order.
160
160
  */
161
- dfs(order: 'in' | 'pre' | 'post'): E[] {
161
+ dfs(order: HeapDFSOrderPattern): E[] {
162
162
  const result: E[] = [];
163
163
 
164
164
  // Auxiliary recursive function, traverses the binary heap according to the traversal order
@@ -227,7 +227,7 @@ export class Heap<E> {
227
227
  * @param comparator - Comparison function.
228
228
  * @returns A new Heap instance.
229
229
  */
230
- static heapify<E>(nodes: E[], comparator: CompareFunction<E>): Heap<E> {
230
+ static heapify<E>(nodes: E[], comparator: HeapComparator<E>): Heap<E> {
231
231
  const binaryHeap = new Heap<E>(comparator);
232
232
  binaryHeap.nodes = [...nodes];
233
233
  binaryHeap.fix(); // Fix heap properties
@@ -7,11 +7,11 @@
7
7
  */
8
8
 
9
9
  import {Heap} from './heap';
10
- import type {CompareFunction} from '../../types';
10
+ import type {HeapComparator} from '../../types';
11
11
 
12
12
  export class MaxHeap<E = any> extends Heap<E> {
13
13
  constructor(
14
- comparator: CompareFunction<E> = (a: E, b: E) => {
14
+ comparator: HeapComparator<E> = (a: E, b: E) => {
15
15
  if (!(typeof a === 'number' && typeof b === 'number')) {
16
16
  throw new Error('The a, b params of compare function must be number');
17
17
  } else {
@@ -7,11 +7,11 @@
7
7
  */
8
8
 
9
9
  import {Heap} from './heap';
10
- import type {CompareFunction} from '../../types';
10
+ import type {HeapComparator} from '../../types';
11
11
 
12
12
  export class MinHeap<E = any> extends Heap<E> {
13
13
  constructor(
14
- comparator: CompareFunction<E> = (a: E, b: E) => {
14
+ comparator: HeapComparator<E> = (a: E, b: E) => {
15
15
  if (!(typeof a === 'number' && typeof b === 'number')) {
16
16
  throw new Error('The a, b params of compare function must be number');
17
17
  } else {
@@ -6,11 +6,11 @@
6
6
  * @license MIT License
7
7
  */
8
8
  import {PriorityQueue} from './priority-queue';
9
- import type {CompareFunction} from '../../types';
9
+ import type {HeapComparator} from '../../types';
10
10
 
11
11
  export class MaxPriorityQueue<E = any> extends PriorityQueue<E> {
12
12
  constructor(
13
- compare: CompareFunction<E> = (a: E, b: E) => {
13
+ compare: HeapComparator<E> = (a: E, b: E) => {
14
14
  if (!(typeof a === 'number' && typeof b === 'number')) {
15
15
  throw new Error('The a, b params of compare function must be number');
16
16
  } else {
@@ -6,11 +6,11 @@
6
6
  * @license MIT License
7
7
  */
8
8
  import {PriorityQueue} from './priority-queue';
9
- import type {CompareFunction} from '../../types';
9
+ import type {HeapComparator} from '../../types';
10
10
 
11
11
  export class MinPriorityQueue<E = any> extends PriorityQueue<E> {
12
12
  constructor(
13
- compare: CompareFunction<E> = (a: E, b: E) => {
13
+ compare: HeapComparator<E> = (a: E, b: E) => {
14
14
  if (!(typeof a === 'number' && typeof b === 'number')) {
15
15
  throw new Error('The a, b params of compare function must be number');
16
16
  } else {
@@ -7,10 +7,10 @@
7
7
  */
8
8
 
9
9
  import {Heap} from '../heap';
10
- import {CompareFunction} from '../../types';
10
+ import {HeapComparator} from '../../types';
11
11
 
12
12
  export class PriorityQueue<E> extends Heap<E> {
13
- constructor(comparator: CompareFunction<E>) {
13
+ constructor(comparator: HeapComparator<E>) {
14
14
  super(comparator);
15
15
  }
16
16
  }
@@ -1,7 +1,10 @@
1
1
  import {BinaryTreeNode} from '../data-structures';
2
- import {IAbstractBinaryTree, IAbstractBinaryTreeNode} from './abstract-binary-tree';
2
+ import {BinaryTreeDeletedResult, BinaryTreeNodeKey} from '../types';
3
3
 
4
- export interface IBinaryTreeNode<T, NEIGHBOR extends IBinaryTreeNode<T, NEIGHBOR>>
5
- extends IAbstractBinaryTreeNode<T, NEIGHBOR> {}
4
+ export interface IBinaryTree<N extends BinaryTreeNode<N['val'], N>> {
5
+ createNode(key: BinaryTreeNodeKey, val?: N['val']): N;
6
6
 
7
- export interface IBinaryTree<N extends BinaryTreeNode<N['val'], N>> extends IAbstractBinaryTree<N> {}
7
+ add(keyOrNode: BinaryTreeNodeKey | N | null, val?: N['val']): N | null | undefined;
8
+
9
+ remove(nodeOrKey: N | BinaryTreeNodeKey): BinaryTreeDeletedResult<N>[];
10
+ }
@@ -1,6 +1,6 @@
1
1
  import {VertexKey} from '../types';
2
2
 
3
- export interface IAbstractGraph<V, E> {
3
+ export interface IGraph<V, E> {
4
4
  createVertex(key: VertexKey, val?: V): V;
5
5
 
6
6
  createEdge(srcOrV1: VertexKey | string, destOrV2: VertexKey | string, weight?: number, val?: E): E;
@@ -1,15 +1,8 @@
1
- export * from './abstract-binary-tree';
2
- export * from './abstract-graph';
3
- export * from './avl-tree';
1
+ export * from './graph';
4
2
  export * from './binary-tree';
5
- export * from './bst';
6
- export * from './directed-graph';
7
3
  export * from './doubly-linked-list';
8
4
  export * from './heap';
9
5
  export * from './navigator';
10
6
  export * from './priority-queue';
11
- export * from './rb-tree';
12
7
  export * from './segment-tree';
13
8
  export * from './singly-linked-list';
14
- export * from './tree-multiset';
15
- export * from './undirected-graph';
@@ -1,5 +1,5 @@
1
1
  export type VertexKey = string | number;
2
- export type EdgeKey = string;
2
+
3
3
  export type DijkstraResult<V> = {
4
4
  distMap: Map<V, number>;
5
5
  distPaths?: Map<V, V[]>;
@@ -1,5 +1,45 @@
1
1
  import {BinaryTreeNode} from '../../data-structures/binary-tree';
2
- import {AbstractBinaryTreeOptions, LoopType} from './abstract-binary-tree';
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
+ export enum FamilyPosition {
16
+ ROOT = 'ROOT',
17
+ LEFT = 'LEFT',
18
+ RIGHT = 'RIGHT',
19
+ ROOT_LEFT = 'ROOT_LEFT',
20
+ ROOT_RIGHT = 'ROOT_RIGHT',
21
+ ISOLATED = 'ISOLATED',
22
+ MAL_NODE = 'MAL_NODE'
23
+ }
24
+
25
+ export type BinaryTreeNodePropertyName = 'key' | 'val';
26
+
27
+ export type NodeOrPropertyName = 'node' | BinaryTreeNodePropertyName;
28
+
29
+ export type DFSOrderPattern = 'in' | 'pre' | 'post';
30
+
31
+ export type BinaryTreeNodeKey = number;
32
+
33
+ export type BinaryTreeNodeProperty<N extends BinaryTreeNode<N['val'], N>> =
34
+ | N['val']
35
+ | N
36
+ | number
37
+ | BinaryTreeNodeKey;
38
+ export type BinaryTreeDeletedResult<N> = { deleted: N | null | undefined; needBalanced: N | null };
39
+
40
+ export type BinaryTreeNodeProperties<N extends BinaryTreeNode<N['val'], N>> =
41
+ BinaryTreeNodeProperty<N>[];
3
42
 
4
43
  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 & { loopType?: LoopType }
44
+
45
+ export type BinaryTreeOptions = { loopType?: LoopType }
@@ -1,11 +1,11 @@
1
1
  import {BSTNode} from '../../data-structures/binary-tree';
2
- import type {BinaryTreeOptions} from './binary-tree';
3
- import {BinaryTreeNodeKey} from './abstract-binary-tree';
2
+ import type {BinaryTreeNodeKey, BinaryTreeOptions} from './binary-tree';
4
3
 
5
4
  export type BSTComparator = (a: BinaryTreeNodeKey, b: BinaryTreeNodeKey) => number;
6
5
 
7
6
  // prettier-ignore
8
7
  export type BSTNodeNested<T> = BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
8
+
9
9
  export type BSTOptions = BinaryTreeOptions & {
10
10
  comparator?: BSTComparator,
11
11
  }
@@ -1 +1,3 @@
1
- export type CompareFunction<T> = (a: T, b: T) => number;
1
+ export type HeapComparator<T> = (a: T, b: T) => number;
2
+
3
+ export type HeapDFSOrderPattern = 'pre' | 'in' | 'post';
@@ -5,10 +5,8 @@ export * from './segment-tree';
5
5
  export * from './tree-multiset';
6
6
  export * from './abstract-graph';
7
7
  export * from './map-graph';
8
- export * from './abstract-binary-tree';
9
8
  export * from './rb-tree';
10
9
  export * from './directed-graph';
11
- export * from './priority-queue';
12
10
  export * from './heap';
13
11
  export * from './singly-linked-list';
14
12
  export * from './doubly-linked-list';
@@ -1,4 +1,5 @@
1
1
  export type Direction = 'up' | 'right' | 'down' | 'left';
2
+
2
3
  export type Turning = {[key in Direction]: Direction};
3
4
 
4
5
  export type NavigatorParams<T = any> = {
@@ -1,7 +1,7 @@
1
- import {CompareFunction, MaxHeap} from '../../../../src';
1
+ import {HeapComparator, MaxHeap} from '../../../../src';
2
2
 
3
3
  describe('MaxHeap', () => {
4
- const numberComparator: CompareFunction<number> = (a, b) => b - a;
4
+ const numberComparator: HeapComparator<number> = (a, b) => b - a;
5
5
  let maxHeap: MaxHeap<number>;
6
6
 
7
7
  beforeEach(() => {
@@ -1,7 +1,7 @@
1
- import {CompareFunction, MinHeap} from '../../../../src';
1
+ import {HeapComparator, MinHeap} from '../../../../src';
2
2
 
3
3
  describe('MinHeap', () => {
4
- const numberComparator: CompareFunction<number> = (a, b) => a - b;
4
+ const numberComparator: HeapComparator<number> = (a, b) => a - b;
5
5
  let minHeap: MinHeap<number>;
6
6
 
7
7
  beforeEach(() => {