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 22const Node = require ( './node' ) ;
33const Stack = require ( '../stacks/stack' ) ;
44const Queue = require ( '../queues/queue' ) ;
5+ const HashMap = require ( '../hash-maps/hash-map' ) ;
56
67/**
78 * Graph that uses an adjacent list
@@ -29,6 +30,7 @@ class Graph {
2930 * @param {Symbol } edgeDirection either `Graph.DIRECTED` or `Graph.UNDIRECTED`
3031 */
3132 constructor ( edgeDirection = Graph . DIRECTED ) {
33+ // this.nodes = new HashMap();
3234 this . nodes = new Map ( ) ;
3335 this . edgeDirection = edgeDirection ;
3436 }
Original file line number Diff line number Diff line change 11/**
2- * Graph node/vertex that hold adjacencies
2+ * Graph node/vertex that hold adjacencies nodes
33 */
44class Node {
55 constructor ( value ) {
Original file line number Diff line number Diff line change @@ -168,6 +168,27 @@ class HashMap {
168168 return acc ;
169169 } , [ ] ) ;
170170 }
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+ }
171192}
172193
173194module . 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