Skip to content

Commit

Permalink
Turn internal Node types into classes
Browse files Browse the repository at this point in the history
  • Loading branch information
felipernb committed Jun 14, 2017
1 parent 021cf0a commit 6d2de49
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 22 deletions.
14 changes: 8 additions & 6 deletions src/data_structures/avl_tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -519,12 +519,14 @@ class AVLTree {
/**
* Tree node
*/
function Node(value, left, right, parent, height) {
this.value = value;
this.left = left;
this.right = right;
this.parent = parent;
this.height = height;
class Node {
constructor(value, left, right, parent, height) {
this.value = value;
this.left = left;
this.right = right;
this.parent = parent;
this.height = height;
}
}

module.exports = AVLTree;
12 changes: 7 additions & 5 deletions src/data_structures/bst.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,13 @@ class BST {
/**
* Tree node
*/
function Node(value, parent) {
this.value = value;
this.parent = parent;
this.left = null;
this.right = null;
class Node {
constructor(value, parent) {
this.value = value;
this.parent = parent;
this.left = null;
this.right = null;
}
}

module.exports = BST;
22 changes: 11 additions & 11 deletions src/data_structures/linked_list.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
/**
* A linked list node
*/
class Node {
constructor(value) {
this.value = value;
this.prev = null;
this.next = null;
}
}

/**
* Doubly-linked list
*/
Expand Down Expand Up @@ -146,4 +135,15 @@ class LinkedList {
}
}

/**
* A linked list node
*/
class Node {
constructor(value) {
this.value = value;
this.prev = null;
this.next = null;
}
}

module.exports = LinkedList;

0 comments on commit 6d2de49

Please sign in to comment.