File tree Expand file tree Collapse file tree 4 files changed +36
-1
lines changed Expand file tree Collapse file tree 4 files changed +36
-1
lines changed Original file line number Diff line number Diff line change 2
2
const Node = require('./node');
3
3
const Stack = require('../stacks/stack');
4
4
const Queue = require('../queues/queue');
5
+ const HashMap = require('../hash-maps/hash-map');
5
6
6
7
/**
7
8
* Graph that uses an adjacent list
@@ -29,6 +30,7 @@ class Graph {
29
30
* @param {Symbol} edgeDirection either `Graph.DIRECTED` or `Graph.UNDIRECTED`
30
31
*/
31
32
constructor(edgeDirection = Graph.DIRECTED) {
33
+ // this.nodes = new HashMap();
32
34
this.nodes = new Map();
33
35
this.edgeDirection = edgeDirection;
34
36
}
Original file line number Diff line number Diff line change 1
1
/**
2
- * Graph node/vertex that hold adjacencies
2
+ * Graph node/vertex that hold adjacencies nodes
3
3
*/
4
4
class Node {
5
5
constructor(value) {
Original file line number Diff line number Diff line change @@ -168,6 +168,27 @@ class HashMap {
168
168
return acc;
169
169
}, []);
170
170
}
171
+
172
+ /**
173
+ * The values() method returns a new Iterator object that
174
+ * contains the values for each element in the Map object
175
+ * in insertion order.
176
+ *
177
+ * @example
178
+ * const myMap = new HashMap();
179
+ * myMap.set('0', 'foo');
180
+ * myMap.set(1, 'bar');
181
+ * myMap.set({}, 'baz');
182
+ *
183
+ * var mapIter = myMap.values();
184
+ *
185
+ * console.log(mapIter.next().value); // "foo"
186
+ * console.log(mapIter.next().value); // "bar"
187
+ * console.log(mapIter.next().value); // "baz"
188
+ */
189
+ values() {
190
+ throw new Error('Not implemented');
191
+ }
171
192
}
172
193
173
194
module.exports = HashMap;
Original file line number Diff line number Diff line change
1
+ /**
2
+ * Binary Tree Node
3
+ */
4
+ class TreeNode {
5
+ constructor(value) {
6
+ this.value = value;
7
+ this.left = null;
8
+ this.right = null;
9
+ }
10
+ }
11
+
12
+ module.exports = TreeNode;
You can’t perform that action at this time.
0 commit comments