data-structure-typed 1.34.7 → 1.34.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 (167) hide show
  1. package/.eslintrc.js +1 -0
  2. package/CHANGELOG.md +1 -1
  3. package/CONTRIBUTING.md +0 -0
  4. package/README.md +8 -8
  5. package/dist/data-structures/binary-tree/aa-tree.js +2 -5
  6. package/dist/data-structures/binary-tree/aa-tree.js.map +1 -1
  7. package/dist/data-structures/binary-tree/abstract-binary-tree.js +314 -457
  8. package/dist/data-structures/binary-tree/abstract-binary-tree.js.map +1 -1
  9. package/dist/data-structures/binary-tree/avl-tree.js +64 -90
  10. package/dist/data-structures/binary-tree/avl-tree.js.map +1 -1
  11. package/dist/data-structures/binary-tree/b-tree.js +2 -5
  12. package/dist/data-structures/binary-tree/b-tree.js.map +1 -1
  13. package/dist/data-structures/binary-tree/binary-indexed-tree.js +17 -22
  14. package/dist/data-structures/binary-tree/binary-indexed-tree.js.map +1 -1
  15. package/dist/data-structures/binary-tree/binary-tree.js +12 -31
  16. package/dist/data-structures/binary-tree/binary-tree.js.map +1 -1
  17. package/dist/data-structures/binary-tree/bst.js +157 -244
  18. package/dist/data-structures/binary-tree/bst.js.map +1 -1
  19. package/dist/data-structures/binary-tree/rb-tree.js +20 -44
  20. package/dist/data-structures/binary-tree/rb-tree.js.map +1 -1
  21. package/dist/data-structures/binary-tree/segment-tree.js +80 -122
  22. package/dist/data-structures/binary-tree/segment-tree.js.map +1 -1
  23. package/dist/data-structures/binary-tree/splay-tree.js +2 -5
  24. package/dist/data-structures/binary-tree/splay-tree.js.map +1 -1
  25. package/dist/data-structures/binary-tree/tree-multiset.js +168 -239
  26. package/dist/data-structures/binary-tree/tree-multiset.js.map +1 -1
  27. package/dist/data-structures/binary-tree/two-three-tree.js +2 -5
  28. package/dist/data-structures/binary-tree/two-three-tree.js.map +1 -1
  29. package/dist/data-structures/graph/abstract-graph.js +351 -585
  30. package/dist/data-structures/graph/abstract-graph.js.map +1 -1
  31. package/dist/data-structures/graph/directed-graph.js +152 -282
  32. package/dist/data-structures/graph/directed-graph.js.map +1 -1
  33. package/dist/data-structures/graph/map-graph.js +47 -88
  34. package/dist/data-structures/graph/map-graph.js.map +1 -1
  35. package/dist/data-structures/graph/undirected-graph.js +91 -180
  36. package/dist/data-structures/graph/undirected-graph.js.map +1 -1
  37. package/dist/data-structures/hash/coordinate-map.js +23 -45
  38. package/dist/data-structures/hash/coordinate-map.js.map +1 -1
  39. package/dist/data-structures/hash/coordinate-set.js +20 -42
  40. package/dist/data-structures/hash/coordinate-set.js.map +1 -1
  41. package/dist/data-structures/hash/hash-map.js +85 -247
  42. package/dist/data-structures/hash/hash-map.js.map +1 -1
  43. package/dist/data-structures/hash/hash-table.js +87 -128
  44. package/dist/data-structures/hash/hash-table.js.map +1 -1
  45. package/dist/data-structures/hash/pair.js +2 -5
  46. package/dist/data-structures/hash/pair.js.map +1 -1
  47. package/dist/data-structures/hash/tree-map.js +2 -5
  48. package/dist/data-structures/hash/tree-map.js.map +1 -1
  49. package/dist/data-structures/hash/tree-set.js +2 -5
  50. package/dist/data-structures/hash/tree-set.js.map +1 -1
  51. package/dist/data-structures/heap/heap.js +56 -80
  52. package/dist/data-structures/heap/heap.js.map +1 -1
  53. package/dist/data-structures/heap/max-heap.js +8 -26
  54. package/dist/data-structures/heap/max-heap.js.map +1 -1
  55. package/dist/data-structures/heap/min-heap.js +8 -26
  56. package/dist/data-structures/heap/min-heap.js.map +1 -1
  57. package/dist/data-structures/linked-list/doubly-linked-list.js +149 -218
  58. package/dist/data-structures/linked-list/doubly-linked-list.js.map +1 -1
  59. package/dist/data-structures/linked-list/singly-linked-list.js +119 -218
  60. package/dist/data-structures/linked-list/singly-linked-list.js.map +1 -1
  61. package/dist/data-structures/linked-list/skip-linked-list.js +50 -70
  62. package/dist/data-structures/linked-list/skip-linked-list.js.map +1 -1
  63. package/dist/data-structures/matrix/matrix.js +7 -8
  64. package/dist/data-structures/matrix/matrix.js.map +1 -1
  65. package/dist/data-structures/matrix/matrix2d.js +57 -70
  66. package/dist/data-structures/matrix/matrix2d.js.map +1 -1
  67. package/dist/data-structures/matrix/navigator.js +18 -37
  68. package/dist/data-structures/matrix/navigator.js.map +1 -1
  69. package/dist/data-structures/matrix/vector2d.js +63 -84
  70. package/dist/data-structures/matrix/vector2d.js.map +1 -1
  71. package/dist/data-structures/priority-queue/max-priority-queue.js +13 -41
  72. package/dist/data-structures/priority-queue/max-priority-queue.js.map +1 -1
  73. package/dist/data-structures/priority-queue/min-priority-queue.js +13 -41
  74. package/dist/data-structures/priority-queue/min-priority-queue.js.map +1 -1
  75. package/dist/data-structures/priority-queue/priority-queue.js +93 -139
  76. package/dist/data-structures/priority-queue/priority-queue.js.map +1 -1
  77. package/dist/data-structures/queue/deque.js +82 -128
  78. package/dist/data-structures/queue/deque.js.map +1 -1
  79. package/dist/data-structures/queue/queue.js +57 -157
  80. package/dist/data-structures/queue/queue.js.map +1 -1
  81. package/dist/data-structures/stack/stack.js +21 -22
  82. package/dist/data-structures/stack/stack.js.map +1 -1
  83. package/dist/data-structures/tree/tree.js +33 -46
  84. package/dist/data-structures/tree/tree.js.map +1 -1
  85. package/dist/data-structures/trie/trie.js +93 -200
  86. package/dist/data-structures/trie/trie.js.map +1 -1
  87. package/dist/types/data-structures/abstract-binary-tree.js.map +1 -1
  88. package/dist/utils/utils.js +22 -107
  89. package/dist/utils/utils.js.map +1 -1
  90. package/lib/data-structures/binary-tree/abstract-binary-tree.d.ts +124 -123
  91. package/lib/data-structures/binary-tree/abstract-binary-tree.js +136 -216
  92. package/lib/data-structures/binary-tree/avl-tree.d.ts +19 -10
  93. package/lib/data-structures/binary-tree/avl-tree.js +35 -13
  94. package/lib/data-structures/binary-tree/binary-tree.d.ts +6 -6
  95. package/lib/data-structures/binary-tree/binary-tree.js +7 -7
  96. package/lib/data-structures/binary-tree/bst.d.ts +34 -34
  97. package/lib/data-structures/binary-tree/bst.js +86 -89
  98. package/lib/data-structures/binary-tree/rb-tree.d.ts +3 -3
  99. package/lib/data-structures/binary-tree/rb-tree.js +4 -4
  100. package/lib/data-structures/binary-tree/tree-multiset.d.ts +40 -42
  101. package/lib/data-structures/binary-tree/tree-multiset.js +76 -86
  102. package/lib/data-structures/graph/abstract-graph.d.ts +62 -62
  103. package/lib/data-structures/graph/abstract-graph.js +86 -86
  104. package/lib/data-structures/graph/directed-graph.d.ts +51 -51
  105. package/lib/data-structures/graph/directed-graph.js +63 -63
  106. package/lib/data-structures/graph/map-graph.d.ts +13 -13
  107. package/lib/data-structures/graph/map-graph.js +12 -12
  108. package/lib/data-structures/graph/undirected-graph.d.ts +30 -30
  109. package/lib/data-structures/graph/undirected-graph.js +32 -32
  110. package/lib/data-structures/priority-queue/priority-queue.d.ts +3 -3
  111. package/lib/data-structures/priority-queue/priority-queue.js +3 -3
  112. package/lib/data-structures/tree/tree.d.ts +4 -4
  113. package/lib/data-structures/tree/tree.js +6 -6
  114. package/lib/interfaces/abstract-binary-tree.d.ts +37 -42
  115. package/lib/interfaces/abstract-graph.d.ts +13 -13
  116. package/lib/interfaces/avl-tree.d.ts +6 -4
  117. package/lib/interfaces/bst.d.ts +10 -9
  118. package/lib/interfaces/directed-graph.d.ts +5 -5
  119. package/lib/interfaces/rb-tree.d.ts +2 -2
  120. package/lib/interfaces/undirected-graph.d.ts +2 -2
  121. package/lib/types/data-structures/abstract-binary-tree.d.ts +3 -3
  122. package/lib/types/data-structures/abstract-binary-tree.js +0 -1
  123. package/lib/types/data-structures/abstract-graph.d.ts +2 -2
  124. package/lib/types/data-structures/bst.d.ts +2 -2
  125. package/lib/types/data-structures/tree-multiset.d.ts +1 -1
  126. package/lib/types/utils/validate-type.d.ts +8 -8
  127. package/package.json +6 -6
  128. package/scripts/rename_clear_files.sh +29 -0
  129. package/src/data-structures/binary-tree/abstract-binary-tree.ts +241 -293
  130. package/src/data-structures/binary-tree/avl-tree.ts +43 -14
  131. package/src/data-structures/binary-tree/binary-tree.ts +8 -8
  132. package/src/data-structures/binary-tree/bst.ts +101 -96
  133. package/src/data-structures/binary-tree/rb-tree.ts +9 -9
  134. package/src/data-structures/binary-tree/tree-multiset.ts +82 -94
  135. package/src/data-structures/graph/abstract-graph.ts +114 -109
  136. package/src/data-structures/graph/directed-graph.ts +77 -77
  137. package/src/data-structures/graph/map-graph.ts +20 -15
  138. package/src/data-structures/graph/undirected-graph.ts +39 -39
  139. package/src/data-structures/priority-queue/priority-queue.ts +3 -3
  140. package/src/data-structures/tree/tree.ts +7 -7
  141. package/src/interfaces/abstract-binary-tree.ts +37 -50
  142. package/src/interfaces/abstract-graph.ts +13 -13
  143. package/src/interfaces/avl-tree.ts +6 -4
  144. package/src/interfaces/bst.ts +9 -9
  145. package/src/interfaces/directed-graph.ts +5 -5
  146. package/src/interfaces/rb-tree.ts +2 -2
  147. package/src/interfaces/undirected-graph.ts +2 -2
  148. package/src/types/data-structures/abstract-binary-tree.ts +3 -4
  149. package/src/types/data-structures/abstract-graph.ts +2 -2
  150. package/src/types/data-structures/bst.ts +2 -2
  151. package/src/types/data-structures/tree-multiset.ts +1 -1
  152. package/src/types/utils/validate-type.ts +10 -10
  153. package/test/integration/avl-tree.test.ts +24 -24
  154. package/test/integration/bst.test.ts +71 -71
  155. package/test/unit/data-structures/binary-tree/avl-tree.test.ts +28 -28
  156. package/test/unit/data-structures/binary-tree/binary-tree.test.ts +4 -12
  157. package/test/unit/data-structures/binary-tree/bst.test.ts +79 -79
  158. package/test/unit/data-structures/binary-tree/overall.test.ts +20 -20
  159. package/test/unit/data-structures/binary-tree/tree-multiset.test.ts +80 -80
  160. package/test/unit/data-structures/graph/directed-graph.test.ts +8 -8
  161. package/test/unit/data-structures/graph/map-graph.test.ts +4 -4
  162. package/test/unit/data-structures/graph/overall.test.ts +2 -2
  163. package/test/unit/data-structures/graph/undirected-graph.test.ts +1 -1
  164. package/test/unit/data-structures/priority-queue/priority-queue.test.ts +4 -5
  165. package/test/unit/data-structures/tree/tree.test.ts +2 -2
  166. package/umd/bundle.min.js +1 -1
  167. package/umd/bundle.min.js.map +1 -1
@@ -10,21 +10,21 @@ import { AbstractEdge, AbstractGraph, AbstractVertex } from './abstract-graph';
10
10
  export class UndirectedVertex extends AbstractVertex {
11
11
  /**
12
12
  * The constructor function initializes a vertex with an optional value.
13
- * @param {VertexId} id - The `id` parameter is of type `VertexId` and represents the identifier of the vertex. It is
13
+ * @param {VertexKey} key - The `key` parameter is of type `VertexKey` and represents the identifier of the vertex. It is
14
14
  * used to uniquely identify the vertex within a graph or network.
15
15
  * @param {V} [val] - The "val" parameter is an optional parameter of type V. It is used to initialize the value of the
16
16
  * vertex. If no value is provided, the vertex will be initialized with a default value.
17
17
  */
18
- constructor(id, val) {
19
- super(id, val);
18
+ constructor(key, val) {
19
+ super(key, val);
20
20
  }
21
21
  }
22
22
  export class UndirectedEdge extends AbstractEdge {
23
23
  /**
24
24
  * The constructor function creates an instance of a class with two vertex IDs, an optional weight, and an optional
25
25
  * value.
26
- * @param {VertexId} v1 - The first vertex ID of the edge.
27
- * @param {VertexId} v2 - The parameter `v2` is a `VertexId`, which represents the identifier of the second vertex in a
26
+ * @param {VertexKey} v1 - The first vertex ID of the edge.
27
+ * @param {VertexKey} v2 - The parameter `v2` is a `VertexKey`, which represents the identifier of the second vertex in a
28
28
  * graph edge.
29
29
  * @param {number} [weight] - The weight parameter is an optional number that represents the weight of the edge.
30
30
  * @param {V} [val] - The "val" parameter is an optional parameter of type V. It is used to store a value associated
@@ -54,20 +54,20 @@ export class UndirectedGraph extends AbstractGraph {
54
54
  }
55
55
  /**
56
56
  * The function creates a new vertex with an optional value and returns it.
57
- * @param {VertexId} id - The `id` parameter is the unique identifier for the vertex. It is used to distinguish one
57
+ * @param {VertexKey} key - The `key` parameter is the unique identifier for the vertex. It is used to distinguish one
58
58
  * vertex from another in the graph.
59
59
  * @param [val] - The `val` parameter is an optional value that can be assigned to the vertex. If a value is provided,
60
- * it will be used as the value of the vertex. If no value is provided, the `id` parameter will be used as the value of
60
+ * it will be used as the value of the vertex. If no value is provided, the `key` parameter will be used as the value of
61
61
  * the vertex.
62
62
  * @returns The method is returning a new instance of the `UndirectedVertex` class, casted as type `V`.
63
63
  */
64
- createVertex(id, val) {
65
- return new UndirectedVertex(id, val !== null && val !== void 0 ? val : id);
64
+ createVertex(key, val) {
65
+ return new UndirectedVertex(key, val !== null && val !== void 0 ? val : key);
66
66
  }
67
67
  /**
68
68
  * The function creates an undirected edge between two vertices with an optional weight and value.
69
- * @param {VertexId} v1 - The parameter `v1` represents the first vertex of the edge.
70
- * @param {VertexId} v2 - The parameter `v2` represents the second vertex of the edge.
69
+ * @param {VertexKey} v1 - The parameter `v1` represents the first vertex of the edge.
70
+ * @param {VertexKey} v2 - The parameter `v2` represents the second vertex of the edge.
71
71
  * @param {number} [weight] - The `weight` parameter is an optional number that represents the weight of the edge. If
72
72
  * no weight is provided, it defaults to 1.
73
73
  * @param [val] - The `val` parameter is an optional value that can be assigned to the edge. It can be of any type and
@@ -79,10 +79,10 @@ export class UndirectedGraph extends AbstractGraph {
79
79
  }
80
80
  /**
81
81
  * The function `getEdge` returns the first edge that connects two vertices, or null if no such edge exists.
82
- * @param {V | null | VertexId} v1 - The parameter `v1` represents a vertex or vertex ID. It can be of type `V` (vertex
83
- * object), `null`, or `VertexId` (a string or number representing the ID of a vertex).
84
- * @param {V | null | VertexId} v2 - The parameter `v2` represents a vertex or vertex ID. It can be of type `V` (vertex
85
- * object), `null`, or `VertexId` (vertex ID).
82
+ * @param {V | null | VertexKey} v1 - The parameter `v1` represents a vertex or vertex ID. It can be of type `V` (vertex
83
+ * object), `null`, or `VertexKey` (a string or number representing the ID of a vertex).
84
+ * @param {V | null | VertexKey} v2 - The parameter `v2` represents a vertex or vertex ID. It can be of type `V` (vertex
85
+ * object), `null`, or `VertexKey` (vertex ID).
86
86
  * @returns an edge (E) or null.
87
87
  */
88
88
  getEdge(v1, v2) {
@@ -92,16 +92,16 @@ export class UndirectedGraph extends AbstractGraph {
92
92
  const vertex1 = this._getVertex(v1);
93
93
  const vertex2 = this._getVertex(v2);
94
94
  if (vertex1 && vertex2) {
95
- edges = (_a = this._edges.get(vertex1)) === null || _a === void 0 ? void 0 : _a.filter(e => e.vertices.includes(vertex2.id));
95
+ edges = (_a = this._edges.get(vertex1)) === null || _a === void 0 ? void 0 : _a.filter(e => e.vertices.includes(vertex2.key));
96
96
  }
97
97
  }
98
98
  return edges ? edges[0] || null : null;
99
99
  }
100
100
  /**
101
101
  * The function removes an edge between two vertices in a graph and returns the removed edge.
102
- * @param {V | VertexId} v1 - The parameter `v1` represents either a vertex object (`V`) or a vertex ID (`VertexId`).
103
- * @param {V | VertexId} v2 - V | VertexId - This parameter can be either a vertex object (V) or a vertex ID
104
- * (VertexId). It represents the second vertex of the edge that needs to be removed.
102
+ * @param {V | VertexKey} v1 - The parameter `v1` represents either a vertex object (`V`) or a vertex ID (`VertexKey`).
103
+ * @param {V | VertexKey} v2 - V | VertexKey - This parameter can be either a vertex object (V) or a vertex ID
104
+ * (VertexKey). It represents the second vertex of the edge that needs to be removed.
105
105
  * @returns the removed edge (E) if it exists, or null if either of the vertices (V) does not exist.
106
106
  */
107
107
  removeEdgeBetween(v1, v2) {
@@ -113,11 +113,11 @@ export class UndirectedGraph extends AbstractGraph {
113
113
  const v1Edges = this._edges.get(vertex1);
114
114
  let removed = null;
115
115
  if (v1Edges) {
116
- removed = arrayRemove(v1Edges, (e) => e.vertices.includes(vertex2.id))[0] || null;
116
+ removed = arrayRemove(v1Edges, (e) => e.vertices.includes(vertex2.key))[0] || null;
117
117
  }
118
118
  const v2Edges = this._edges.get(vertex2);
119
119
  if (v2Edges) {
120
- arrayRemove(v2Edges, (e) => e.vertices.includes(vertex1.id));
120
+ arrayRemove(v2Edges, (e) => e.vertices.includes(vertex1.key));
121
121
  }
122
122
  return removed;
123
123
  }
@@ -132,13 +132,13 @@ export class UndirectedGraph extends AbstractGraph {
132
132
  /**
133
133
  * The function `degreeOf` returns the degree of a vertex in a graph, which is the number of edges connected to that
134
134
  * vertex.
135
- * @param {VertexId | V} vertexOrId - The parameter `vertexOrId` can be either a `VertexId` or a `V`.
135
+ * @param {VertexKey | V} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `V`.
136
136
  * @returns The function `degreeOf` returns the degree of a vertex in a graph. The degree of a vertex is the number of
137
137
  * edges connected to that vertex.
138
138
  */
139
- degreeOf(vertexOrId) {
139
+ degreeOf(vertexOrKey) {
140
140
  var _a;
141
- const vertex = this._getVertex(vertexOrId);
141
+ const vertex = this._getVertex(vertexOrKey);
142
142
  if (vertex) {
143
143
  return ((_a = this._edges.get(vertex)) === null || _a === void 0 ? void 0 : _a.length) || 0;
144
144
  }
@@ -148,12 +148,12 @@ export class UndirectedGraph extends AbstractGraph {
148
148
  }
149
149
  /**
150
150
  * The function returns the edges of a given vertex or vertex ID.
151
- * @param {VertexId | V} vertexOrId - The parameter `vertexOrId` can be either a `VertexId` or a `V`. A `VertexId` is a
151
+ * @param {VertexKey | V} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `V`. A `VertexKey` is a
152
152
  * unique identifier for a vertex in a graph, while `V` represents the type of the vertex.
153
153
  * @returns an array of edges.
154
154
  */
155
- edgesOf(vertexOrId) {
156
- const vertex = this._getVertex(vertexOrId);
155
+ edgesOf(vertexOrKey) {
156
+ const vertex = this._getVertex(vertexOrKey);
157
157
  if (vertex) {
158
158
  return this._edges.get(vertex) || [];
159
159
  }
@@ -176,17 +176,17 @@ export class UndirectedGraph extends AbstractGraph {
176
176
  }
177
177
  /**
178
178
  * The function "getNeighbors" returns an array of neighboring vertices for a given vertex or vertex ID.
179
- * @param {V | VertexId} vertexOrId - The parameter `vertexOrId` can be either a vertex object (`V`) or a vertex ID
180
- * (`VertexId`).
179
+ * @param {V | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`V`) or a vertex ID
180
+ * (`VertexKey`).
181
181
  * @returns an array of vertices (V[]).
182
182
  */
183
- getNeighbors(vertexOrId) {
183
+ getNeighbors(vertexOrKey) {
184
184
  const neighbors = [];
185
- const vertex = this._getVertex(vertexOrId);
185
+ const vertex = this._getVertex(vertexOrKey);
186
186
  if (vertex) {
187
187
  const neighborEdges = this.edgesOf(vertex);
188
188
  for (const edge of neighborEdges) {
189
- const neighbor = this._getVertex(edge.vertices.filter(e => e !== vertex.id)[0]);
189
+ const neighbor = this._getVertex(edge.vertices.filter(e => e !== vertex.key)[0]);
190
190
  if (neighbor) {
191
191
  neighbors.push(neighbor);
192
192
  }
@@ -104,13 +104,13 @@ export declare class PriorityQueue<E = any> {
104
104
  */
105
105
  sort(): E[];
106
106
  /**
107
- * The DFS function performs a depth-first search traversal on a binary tree and returns an array of visited nodes
107
+ * The dfs function performs a depth-first search traversal on a binary tree and returns an array of visited nodes
108
108
  * based on the specified traversal order.
109
109
  * @param {PriorityQueueDFSOrderPattern} dfsMode - The dfsMode parameter is a string that specifies the order in which
110
- * the nodes should be visited during the Depth-First Search (DFS) traversal. It can have one of the following values:
110
+ * the nodes should be visited during the Depth-First Search (dfs) traversal. It can have one of the following values:
111
111
  * @returns an array of type `(E | null)[]`.
112
112
  */
113
- DFS(dfsMode: PriorityQueueDFSOrderPattern): (E | null)[];
113
+ dfs(dfsMode: PriorityQueueDFSOrderPattern): (E | null)[];
114
114
  protected _setNodes(value: E[]): void;
115
115
  protected readonly _comparator: PriorityQueueComparator<E>;
116
116
  /**
@@ -174,13 +174,13 @@ export class PriorityQueue {
174
174
  return visitedNode;
175
175
  }
176
176
  /**
177
- * The DFS function performs a depth-first search traversal on a binary tree and returns an array of visited nodes
177
+ * The dfs function performs a depth-first search traversal on a binary tree and returns an array of visited nodes
178
178
  * based on the specified traversal order.
179
179
  * @param {PriorityQueueDFSOrderPattern} dfsMode - The dfsMode parameter is a string that specifies the order in which
180
- * the nodes should be visited during the Depth-First Search (DFS) traversal. It can have one of the following values:
180
+ * the nodes should be visited during the Depth-First Search (dfs) traversal. It can have one of the following values:
181
181
  * @returns an array of type `(E | null)[]`.
182
182
  */
183
- DFS(dfsMode) {
183
+ dfs(dfsMode) {
184
184
  const visitedNode = [];
185
185
  const traverse = (cur) => {
186
186
  var _a, _b, _c;
@@ -1,8 +1,8 @@
1
1
  export declare class TreeNode<V = any> {
2
- constructor(id: string, value?: V, children?: TreeNode<V>[]);
3
- private _id;
4
- get id(): string;
5
- set id(value: string);
2
+ constructor(key: string, value?: V, children?: TreeNode<V>[]);
3
+ private _key;
4
+ get key(): string;
5
+ set key(value: string);
6
6
  private _value?;
7
7
  get value(): V | undefined;
8
8
  set value(value: V | undefined);
@@ -1,14 +1,14 @@
1
1
  export class TreeNode {
2
- constructor(id, value, children) {
3
- this._id = id;
2
+ constructor(key, value, children) {
3
+ this._key = key;
4
4
  this._value = value || undefined;
5
5
  this._children = children || [];
6
6
  }
7
- get id() {
8
- return this._id;
7
+ get key() {
8
+ return this._key;
9
9
  }
10
- set id(value) {
11
- this._id = value;
10
+ set key(value) {
11
+ this._key = value;
12
12
  }
13
13
  get value() {
14
14
  return this._value;
@@ -1,24 +1,19 @@
1
- import { AbstractBinaryTreeNodeProperties, AbstractBinaryTreeNodeProperty, BinaryTreeDeletedResult, BinaryTreeNodeId, BinaryTreeNodePropertyName, DFSOrderPattern, FamilyPosition, LoopType, NodeOrPropertyName } from '../types';
1
+ import { AbstractBinaryTreeNodeProperties, AbstractBinaryTreeNodeProperty, BinaryTreeDeletedResult, BinaryTreeNodeKey, BinaryTreeNodePropertyName, DFSOrderPattern, FamilyPosition, LoopType, NodeOrPropertyName } from '../types';
2
2
  import { AbstractBinaryTreeNode } from '../data-structures';
3
3
  export interface IAbstractBinaryTreeNode<T, NEIGHBOR extends IAbstractBinaryTreeNode<T, NEIGHBOR>> {
4
- get id(): BinaryTreeNodeId;
5
- set id(v: BinaryTreeNodeId);
6
- get val(): T | undefined;
7
- set val(v: T | undefined);
4
+ key: BinaryTreeNodeKey;
5
+ val: T | undefined;
8
6
  get left(): NEIGHBOR | null | undefined;
9
7
  set left(v: NEIGHBOR | null | undefined);
10
8
  get right(): NEIGHBOR | null | undefined;
11
9
  set right(v: NEIGHBOR | null | undefined);
12
- get parent(): NEIGHBOR | null | undefined;
13
- set parent(v: NEIGHBOR | null | undefined);
10
+ parent: NEIGHBOR | null | undefined;
14
11
  get familyPosition(): FamilyPosition;
15
- get height(): number;
16
- set height(v: number);
17
12
  }
18
13
  export interface IAbstractBinaryTree<N extends AbstractBinaryTreeNode<N['val'], N>> {
19
- createNode(id: BinaryTreeNodeId, val?: N['val'], count?: number): N | null;
14
+ createNode(key: BinaryTreeNodeKey, val?: N['val'], count?: number): N | null;
20
15
  get loopType(): LoopType;
21
- get visitedId(): BinaryTreeNodeId[];
16
+ get visitedKey(): BinaryTreeNodeKey[];
22
17
  get visitedVal(): Array<N['val']>;
23
18
  get visitedNode(): N[];
24
19
  get root(): N | null;
@@ -26,17 +21,17 @@ export interface IAbstractBinaryTree<N extends AbstractBinaryTreeNode<N['val'],
26
21
  swapLocation(srcNode: N, destNode: N): N;
27
22
  clear(): void;
28
23
  isEmpty(): boolean;
29
- add(id: BinaryTreeNodeId | N, val?: N['val']): N | null | undefined;
30
- addMany(idsOrNodes: (BinaryTreeNodeId | N | null)[], data?: N['val'][]): (N | null | undefined)[];
31
- fill(idsOrNodes: (BinaryTreeNodeId | N | null)[], data?: N[] | Array<N['val']>): boolean;
32
- remove(id: BinaryTreeNodeId, ignoreCount?: boolean): BinaryTreeDeletedResult<N>[];
24
+ add(key: BinaryTreeNodeKey | N, val?: N['val']): N | null | undefined;
25
+ addMany(keysOrNodes: (BinaryTreeNodeKey | N | null)[], data?: N['val'][]): (N | null | undefined)[];
26
+ refill(keysOrNodes: (BinaryTreeNodeKey | N | null)[], data?: N[] | Array<N['val']>): boolean;
27
+ remove(key: BinaryTreeNodeKey, ignoreCount?: boolean): BinaryTreeDeletedResult<N>[];
33
28
  getDepth(node: N): number;
34
29
  getHeight(beginRoot?: N | null): number;
35
30
  getMinHeight(beginRoot?: N | null): number;
36
31
  isPerfectlyBalanced(beginRoot?: N | null): boolean;
37
- getNodes(nodeProperty: BinaryTreeNodeId | N, propertyName?: BinaryTreeNodePropertyName, onlyOne?: boolean): N[];
38
- has(nodeProperty: BinaryTreeNodeId | N, propertyName?: BinaryTreeNodePropertyName): boolean;
39
- get(nodeProperty: BinaryTreeNodeId | N, propertyName?: BinaryTreeNodePropertyName): N | null;
32
+ getNodes(nodeProperty: BinaryTreeNodeKey | N, propertyName?: BinaryTreeNodePropertyName, onlyOne?: boolean): N[];
33
+ has(nodeProperty: BinaryTreeNodeKey | N, propertyName?: BinaryTreeNodePropertyName): boolean;
34
+ get(nodeProperty: BinaryTreeNodeKey | N, propertyName?: BinaryTreeNodePropertyName): N | null;
40
35
  getPathToRoot(node: N): N[];
41
36
  getLeftMost(): N | null;
42
37
  getLeftMost(node: N): N;
@@ -49,39 +44,39 @@ export interface IAbstractBinaryTree<N extends AbstractBinaryTreeNode<N['val'],
49
44
  getSubTreeSize(subTreeRoot: N | null | undefined): number;
50
45
  subTreeSum(subTreeRoot: N, propertyName?: BinaryTreeNodePropertyName): number;
51
46
  subTreeAdd(subTreeRoot: N, delta: number, propertyName?: BinaryTreeNodePropertyName): boolean;
52
- BFS(): BinaryTreeNodeId[];
53
- BFS(nodeOrPropertyName: 'id'): BinaryTreeNodeId[];
54
- BFS(nodeOrPropertyName: 'val'): N['val'][];
55
- BFS(nodeOrPropertyName: 'node'): N[];
56
- BFS(nodeOrPropertyName: 'count'): number[];
57
- BFS(nodeOrPropertyName?: NodeOrPropertyName): AbstractBinaryTreeNodeProperties<N>;
58
- DFS(): BinaryTreeNodeId[];
59
- DFS(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'id'): BinaryTreeNodeId[];
60
- DFS(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'val'): N[];
61
- DFS(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'node'): N[];
62
- DFS(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'count'): number[];
63
- DFS(pattern?: 'in' | 'pre' | 'post', nodeOrPropertyName?: NodeOrPropertyName): AbstractBinaryTreeNodeProperties<N>;
64
- DFSIterative(): BinaryTreeNodeId[];
65
- DFSIterative(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'id'): BinaryTreeNodeId[];
66
- DFSIterative(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'val'): N[];
67
- DFSIterative(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'node'): N[];
68
- DFSIterative(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'count'): number[];
69
- DFSIterative(pattern?: 'in' | 'pre' | 'post', nodeOrPropertyName?: NodeOrPropertyName): AbstractBinaryTreeNodeProperties<N>;
70
- levelIterative(node: N | null): BinaryTreeNodeId[];
71
- levelIterative(node: N | null, nodeOrPropertyName?: 'id'): BinaryTreeNodeId[];
47
+ bfs(): BinaryTreeNodeKey[];
48
+ bfs(nodeOrPropertyName: 'key'): BinaryTreeNodeKey[];
49
+ bfs(nodeOrPropertyName: 'val'): N['val'][];
50
+ bfs(nodeOrPropertyName: 'node'): N[];
51
+ bfs(nodeOrPropertyName: 'count'): number[];
52
+ bfs(nodeOrPropertyName?: NodeOrPropertyName): AbstractBinaryTreeNodeProperties<N>;
53
+ dfs(): BinaryTreeNodeKey[];
54
+ dfs(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'key'): BinaryTreeNodeKey[];
55
+ dfs(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'val'): N[];
56
+ dfs(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'node'): N[];
57
+ dfs(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'count'): number[];
58
+ dfs(pattern?: 'in' | 'pre' | 'post', nodeOrPropertyName?: NodeOrPropertyName): AbstractBinaryTreeNodeProperties<N>;
59
+ dfsIterative(): BinaryTreeNodeKey[];
60
+ dfsIterative(pattern: DFSOrderPattern): BinaryTreeNodeKey[];
61
+ dfsIterative(pattern: DFSOrderPattern, nodeOrPropertyName: 'key'): BinaryTreeNodeKey[];
62
+ dfsIterative(pattern: DFSOrderPattern, nodeOrPropertyName: 'val'): N['val'][];
63
+ dfsIterative(pattern: DFSOrderPattern, nodeOrPropertyName: 'node'): N[];
64
+ dfsIterative(pattern?: DFSOrderPattern, nodeOrPropertyName?: NodeOrPropertyName): AbstractBinaryTreeNodeProperties<N>;
65
+ levelIterative(node: N | null): BinaryTreeNodeKey[];
66
+ levelIterative(node: N | null, nodeOrPropertyName?: 'key'): BinaryTreeNodeKey[];
72
67
  levelIterative(node: N | null, nodeOrPropertyName?: 'val'): N['val'][];
73
68
  levelIterative(node: N | null, nodeOrPropertyName?: 'node'): N[];
74
69
  levelIterative(node: N | null, nodeOrPropertyName?: 'count'): number[];
75
70
  levelIterative(node: N | null, nodeOrPropertyName?: NodeOrPropertyName): AbstractBinaryTreeNodeProperties<N>;
76
- listLevels(node: N | null): BinaryTreeNodeId[][];
77
- listLevels(node: N | null, nodeOrPropertyName?: 'id'): BinaryTreeNodeId[][];
71
+ listLevels(node: N | null): BinaryTreeNodeKey[][];
72
+ listLevels(node: N | null, nodeOrPropertyName?: 'key'): BinaryTreeNodeKey[][];
78
73
  listLevels(node: N | null, nodeOrPropertyName?: 'val'): N['val'][][];
79
74
  listLevels(node: N | null, nodeOrPropertyName?: 'node'): N[][];
80
75
  listLevels(node: N | null, nodeOrPropertyName?: 'count'): number[][];
81
76
  listLevels(node: N | null, nodeOrPropertyName?: NodeOrPropertyName): AbstractBinaryTreeNodeProperty<N>[][];
82
77
  getPredecessor(node: N): N;
83
- morris(): BinaryTreeNodeId[];
84
- morris(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'id'): BinaryTreeNodeId[];
78
+ morris(): BinaryTreeNodeKey[];
79
+ morris(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'key'): BinaryTreeNodeKey[];
85
80
  morris(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'val'): N[];
86
81
  morris(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'node'): N[];
87
82
  morris(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'count'): number[];
@@ -1,17 +1,17 @@
1
- import { VertexId } from '../types';
1
+ import { VertexKey } from '../types';
2
2
  export interface IAbstractGraph<V, E> {
3
- hasVertex(vertexOrId: V | VertexId): boolean;
4
- addVertex(id: VertexId, val?: V): boolean;
5
- removeVertex(vertexOrId: V | VertexId): boolean;
6
- removeAllVertices(vertices: V[] | VertexId[]): boolean;
7
- degreeOf(vertexOrId: V | VertexId): number;
8
- edgesOf(vertexOrId: V | VertexId): E[];
9
- hasEdge(src: V | VertexId, dest: V | VertexId): boolean;
10
- getEdge(srcOrId: V | VertexId, destOrId: V | VertexId): E | null;
3
+ hasVertex(vertexOrKey: V | VertexKey): boolean;
4
+ addVertex(key: VertexKey, val?: V): boolean;
5
+ removeVertex(vertexOrKey: V | VertexKey): boolean;
6
+ removeAllVertices(vertices: V[] | VertexKey[]): boolean;
7
+ degreeOf(vertexOrKey: V | VertexKey): number;
8
+ edgesOf(vertexOrKey: V | VertexKey): E[];
9
+ hasEdge(src: V | VertexKey, dest: V | VertexKey): boolean;
10
+ getEdge(srcOrKey: V | VertexKey, destOrKey: V | VertexKey): E | null;
11
11
  edgeSet(): E[];
12
- addEdge(src: V | VertexId, dest: V | VertexId, weight: number, val: E): boolean;
12
+ addEdge(src: V | VertexKey, dest: V | VertexKey, weight: number, val: E): boolean;
13
13
  removeEdge(edge: E): E | null;
14
- setEdgeWeight(srcOrId: V | VertexId, destOrId: V | VertexId, weight: number): boolean;
15
- getMinPathBetween(v1: V | VertexId, v2: V | VertexId, isWeight?: boolean): V[] | null;
16
- getNeighbors(vertexOrId: V | VertexId): V[];
14
+ setEdgeWeight(srcOrKey: V | VertexKey, destOrKey: V | VertexKey, weight: number): boolean;
15
+ getMinPathBetween(v1: V | VertexKey, v2: V | VertexKey, isWeight?: boolean): V[] | null;
16
+ getNeighbors(vertexOrKey: V | VertexKey): V[];
17
17
  }
@@ -1,8 +1,10 @@
1
1
  import { AVLTreeNode } from '../data-structures';
2
2
  import { IBST, IBSTNode } from './bst';
3
- import { BinaryTreeDeletedResult, BinaryTreeNodeId } from '../types';
4
- export type IAVLTreeNode<T, NEIGHBOR extends IAVLTreeNode<T, NEIGHBOR>> = IBSTNode<T, NEIGHBOR>;
3
+ import { BinaryTreeDeletedResult, BinaryTreeNodeKey } from '../types';
4
+ export interface IAVLTreeNode<T, NEIGHBOR extends IAVLTreeNode<T, NEIGHBOR>> extends IBSTNode<T, NEIGHBOR> {
5
+ height: number;
6
+ }
5
7
  export interface IAVLTree<N extends AVLTreeNode<N['val'], N>> extends IBST<N> {
6
- add(id: BinaryTreeNodeId, val?: N['val'] | null): N | null | undefined;
7
- remove(id: BinaryTreeNodeId): BinaryTreeDeletedResult<N>[];
8
+ add(key: BinaryTreeNodeKey, val?: N['val'] | null): N | null | undefined;
9
+ remove(key: BinaryTreeNodeKey): BinaryTreeDeletedResult<N>[];
8
10
  }
@@ -1,15 +1,16 @@
1
1
  import { BSTNode } from '../data-structures';
2
2
  import { IBinaryTree, IBinaryTreeNode } from './binary-tree';
3
- import { BinaryTreeDeletedResult, BinaryTreeNodeId, BinaryTreeNodePropertyName } from '../types';
4
- export type IBSTNode<T, NEIGHBOR extends IBSTNode<T, NEIGHBOR>> = IBinaryTreeNode<T, NEIGHBOR>;
3
+ import { BinaryTreeDeletedResult, BinaryTreeNodeKey, BinaryTreeNodePropertyName } from '../types';
4
+ export interface IBSTNode<T, NEIGHBOR extends IBSTNode<T, NEIGHBOR>> extends IBinaryTreeNode<T, NEIGHBOR> {
5
+ }
5
6
  export interface IBST<N extends BSTNode<N['val'], N>> extends IBinaryTree<N> {
6
- createNode(id: BinaryTreeNodeId, val?: N['val'], count?: number): N;
7
- add(id: BinaryTreeNodeId, val?: N['val'] | null, count?: number): N | null | undefined;
8
- get(nodeProperty: BinaryTreeNodeId | N, propertyName?: BinaryTreeNodePropertyName): N | null;
9
- lastKey(): BinaryTreeNodeId;
10
- remove(id: BinaryTreeNodeId, ignoreCount?: boolean): BinaryTreeDeletedResult<N>[];
11
- getNodes(nodeProperty: BinaryTreeNodeId | N, propertyName?: BinaryTreeNodePropertyName, onlyOne?: boolean): N[];
12
- lesserSum(id: BinaryTreeNodeId, propertyName?: BinaryTreeNodePropertyName): number;
7
+ createNode(key: BinaryTreeNodeKey, val?: N['val'], count?: number): N;
8
+ add(key: BinaryTreeNodeKey, val?: N['val'] | null, count?: number): N | null | undefined;
9
+ get(nodeProperty: BinaryTreeNodeKey | N, propertyName?: BinaryTreeNodePropertyName): N | null;
10
+ lastKey(): BinaryTreeNodeKey;
11
+ remove(key: BinaryTreeNodeKey, ignoreCount?: boolean): BinaryTreeDeletedResult<N>[];
12
+ getNodes(nodeProperty: BinaryTreeNodeKey | N, propertyName?: BinaryTreeNodePropertyName, onlyOne?: boolean): N[];
13
+ lesserSum(key: BinaryTreeNodeKey, propertyName?: BinaryTreeNodePropertyName): number;
13
14
  allGreaterNodesAdd(node: N, delta: number, propertyName?: BinaryTreeNodePropertyName): boolean;
14
15
  perfectlyBalance(): boolean;
15
16
  isAVLBalanced(): boolean;
@@ -1,12 +1,12 @@
1
- import { VertexId } from '../types';
1
+ import { VertexKey } from '../types';
2
2
  import { IAbstractGraph } from './abstract-graph';
3
3
  export interface IDirectedGraph<V, E> extends IAbstractGraph<V, E> {
4
4
  incomingEdgesOf(vertex: V): E[];
5
5
  outgoingEdgesOf(vertex: V): E[];
6
- inDegreeOf(vertexOrId: V | VertexId): number;
7
- outDegreeOf(vertexOrId: V | VertexId): number;
6
+ inDegreeOf(vertexOrKey: V | VertexKey): number;
7
+ outDegreeOf(vertexOrKey: V | VertexKey): number;
8
8
  getEdgeSrc(e: E): V | null;
9
9
  getEdgeDest(e: E): V | null;
10
- removeEdgeSrcToDest(srcOrId: V | VertexId, destOrId: V | VertexId): E | null;
11
- removeEdgesBetween(v1: V | VertexId, v2: V | VertexId): E[];
10
+ removeEdgeSrcToDest(srcOrKey: V | VertexKey, destOrKey: V | VertexKey): E | null;
11
+ removeEdgesBetween(v1: V | VertexKey, v2: V | VertexKey): E[];
12
12
  }
@@ -1,7 +1,7 @@
1
1
  import { RBTreeNode } from '../data-structures';
2
2
  import { IBST, IBSTNode } from './bst';
3
- import { BinaryTreeNodeId } from '../types';
3
+ import { BinaryTreeNodeKey } from '../types';
4
4
  export type IRBTreeNode<T, NEIGHBOR extends IRBTreeNode<T, NEIGHBOR>> = IBSTNode<T, NEIGHBOR>;
5
5
  export interface IRBTree<N extends RBTreeNode<N['val'], N>> extends IBST<N> {
6
- createNode(id: BinaryTreeNodeId, val?: N['val'], count?: number): N;
6
+ createNode(key: BinaryTreeNodeKey, val?: N['val'], count?: number): N;
7
7
  }
@@ -1,5 +1,5 @@
1
- import { VertexId } from '../types';
1
+ import { VertexKey } from '../types';
2
2
  import { IAbstractGraph } from './abstract-graph';
3
3
  export interface IUNDirectedGraph<V, E> extends IAbstractGraph<V, E> {
4
- removeEdgeBetween(v1: V | VertexId, v2: V | VertexId): E | null;
4
+ removeEdgeBetween(v1: V | VertexKey, v2: V | VertexKey): E | null;
5
5
  }
@@ -18,15 +18,15 @@ export declare enum FamilyPosition {
18
18
  ISOLATED = "ISOLATED",
19
19
  MAL_NODE = "MAL_NODE"
20
20
  }
21
- export type BinaryTreeNodePropertyName = 'id' | 'val';
21
+ export type BinaryTreeNodePropertyName = 'key' | 'val';
22
22
  export type NodeOrPropertyName = 'node' | BinaryTreeNodePropertyName;
23
23
  export type DFSOrderPattern = 'in' | 'pre' | 'post';
24
- export type BinaryTreeNodeId = number;
24
+ export type BinaryTreeNodeKey = number;
25
25
  export type BinaryTreeDeletedResult<N> = {
26
26
  deleted: N | null | undefined;
27
27
  needBalanced: N | null;
28
28
  };
29
- export type AbstractBinaryTreeNodeProperty<N extends AbstractBinaryTreeNode<N['val'], N>> = N['val'] | N | number | BinaryTreeNodeId;
29
+ export type AbstractBinaryTreeNodeProperty<N extends AbstractBinaryTreeNode<N['val'], N>> = N['val'] | N | number | BinaryTreeNodeKey;
30
30
  export type AbstractBinaryTreeNodeProperties<N extends AbstractBinaryTreeNode<N['val'], N>> = AbstractBinaryTreeNodeProperty<N>[];
31
31
  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>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
32
32
  export type AbstractBinaryTreeOptions = {
@@ -9,7 +9,6 @@ export var LoopType;
9
9
  LoopType["ITERATIVE"] = "ITERATIVE";
10
10
  LoopType["RECURSIVE"] = "RECURSIVE";
11
11
  })(LoopType || (LoopType = {}));
12
- /* 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. */
13
12
  export var FamilyPosition;
14
13
  (function (FamilyPosition) {
15
14
  FamilyPosition["ROOT"] = "ROOT";
@@ -1,5 +1,5 @@
1
- export type VertexId = string | number;
2
- export type EdgeId = string;
1
+ export type VertexKey = string | number;
2
+ export type EdgeKey = string;
3
3
  export type DijkstraResult<V> = {
4
4
  distMap: Map<V, number>;
5
5
  distPaths?: Map<V, V[]>;
@@ -1,7 +1,7 @@
1
1
  import { BSTNode } from '../../data-structures/binary-tree';
2
2
  import type { BinaryTreeOptions } from './binary-tree';
3
- import { BinaryTreeNodeId } from './abstract-binary-tree';
4
- export type BSTComparator = (a: BinaryTreeNodeId, b: BinaryTreeNodeId) => number;
3
+ import { BinaryTreeNodeKey } from './abstract-binary-tree';
4
+ export type BSTComparator = (a: BinaryTreeNodeKey, b: BinaryTreeNodeKey) => number;
5
5
  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>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
6
6
  export type BSTOptions = BinaryTreeOptions & {
7
7
  comparator?: BSTComparator;
@@ -1,4 +1,4 @@
1
1
  import { TreeMultisetNode } from '../../data-structures/binary-tree';
2
2
  import { AVLTreeOptions } from './avl-tree';
3
3
  export type TreeMultisetNodeNested<T> = TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
4
- export type TreeMultisetOptions = Omit<AVLTreeOptions, 'isMergeDuplicatedNodeById'> & {};
4
+ export type TreeMultisetOptions = Omit<AVLTreeOptions, 'isMergeDuplicatedNodeByKey'> & {};
@@ -1,19 +1,19 @@
1
1
  export type KeyValueObject = {
2
2
  [key: string]: any;
3
3
  };
4
- export type KeyValueObjectWithId = {
4
+ export type KeyValueObjectWithKey = {
5
5
  [key: string]: any;
6
- id: string | number | symbol;
6
+ key: string | number | symbol;
7
7
  };
8
8
  export type NonNumberNonObjectButDefined = string | boolean | symbol | null;
9
- export type ObjectWithoutId = Omit<KeyValueObject, 'id'>;
10
- export type ObjectWithNonNumberId = {
9
+ export type ObjectWithoutKey = Omit<KeyValueObject, 'key'>;
10
+ export type ObjectWithNonNumberKey = {
11
11
  [key: string]: any;
12
- id: string | boolean | symbol | null | object | undefined;
12
+ key: string | boolean | symbol | null | object | undefined;
13
13
  };
14
- export type ObjectWithNumberId = {
14
+ export type ObjectWithNumberKey = {
15
15
  [key: string]: any;
16
- id: number;
16
+ key: number;
17
17
  };
18
- export type RestrictValById = NonNumberNonObjectButDefined | ObjectWithoutId | ObjectWithNonNumberId | ObjectWithNumberId;
18
+ export type RestrictValByKey = NonNumberNonObjectButDefined | ObjectWithoutKey | ObjectWithNonNumberKey | ObjectWithNumberKey;
19
19
  export type DummyAny = string | number | boolean | null | undefined | object | symbol | void | ((...args: []) => any) | never;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "data-structure-typed",
3
- "version": "1.34.7",
3
+ "version": "1.34.9",
4
4
  "description": "Data Structures of Javascript & TypeScript. Binary Tree, BST, Graph, Heap, Priority Queue, Linked List, Queue, Deque, Stack, AVL Tree, Tree Multiset, Trie, Directed Graph, Undirected Graph, Singly Linked List, Doubly Linked List, Max Heap, Max Priority Queue, Min Heap, Min Priority Queue.",
5
5
  "main": "dist/index.js",
6
6
  "module": "lib/index.js",
@@ -23,7 +23,7 @@
23
23
  "fix:test": "npm run lint:test && npm run format:test",
24
24
  "fix": "npm run fix:src && npm run fix:test",
25
25
  "update:test-deps": "npm i avl-tree-typed binary-tree-typed bst-typed heap-typed --save-dev",
26
- "update-all:test-deps": "npm i avl-tree-typed binary-tree-typed bst-typed deque-typed directed-graph-typed doubly-linked-list-typed graph-typed heap-typed linked-list-typed max-heap-typed max-priority-queue-typed min-heap-typed min-priority-queue-typed priority-queue-typed singly-linked-list-typed stack-typed tree-multiset-typed trie-typed undirected-graph-typed queue-typed --save-dev",
26
+ "install:individuals": "npm i avl-tree-typed binary-tree-typed bst-typed deque-typed directed-graph-typed doubly-linked-list-typed graph-typed heap-typed linked-list-typed max-heap-typed max-priority-queue-typed min-heap-typed min-priority-queue-typed priority-queue-typed singly-linked-list-typed stack-typed tree-multiset-typed trie-typed undirected-graph-typed queue-typed --save-dev",
27
27
  "test": "jest",
28
28
  "check:deps": "dependency-cruiser src",
29
29
  "changelog": "auto-changelog",
@@ -50,17 +50,17 @@
50
50
  "@typescript-eslint/eslint-plugin": "^6.7.4",
51
51
  "@typescript-eslint/parser": "^6.7.4",
52
52
  "auto-changelog": "^2.4.0",
53
- "avl-tree-typed": "^1.34.1",
53
+ "avl-tree-typed": "^1.34.8",
54
54
  "benchmark": "^2.1.4",
55
- "binary-tree-typed": "^1.34.1",
56
- "bst-typed": "^1.34.1",
55
+ "binary-tree-typed": "^1.34.8",
56
+ "bst-typed": "^1.34.8",
57
57
  "dependency-cruiser": "^14.1.0",
58
58
  "eslint": "^8.50.0",
59
59
  "eslint-config-prettier": "^9.0.0",
60
60
  "eslint-import-resolver-alias": "^1.1.2",
61
61
  "eslint-import-resolver-typescript": "^3.6.1",
62
62
  "eslint-plugin-import": "^2.28.1",
63
- "heap-typed": "^1.34.1",
63
+ "heap-typed": "^1.34.8",
64
64
  "istanbul-badges-readme": "^1.8.5",
65
65
  "jest": "^29.7.0",
66
66
  "prettier": "^3.0.3",