Advertisement
Guest User

TreeNode.java

a guest
Nov 25th, 2014
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.81 KB | None | 0 0
  1. public class TreeNode<T> {
  2.  
  3.     private T value;
  4.     private TreeNode left, right;
  5.  
  6.     public TreeNode(T value) {
  7.         this.value = value;
  8.         this.left = null;
  9.         this.right = null;
  10.     }
  11.  
  12.     public TreeNode(T value, TreeNode left, TreeNode right) {
  13.         this.value = value;
  14.         this.left = left;
  15.         this.right = right;
  16.     }
  17.  
  18.     public void setValue(T newValue) {
  19.         this.value = newValue;
  20.     }
  21.  
  22.     public void setLeft(TreeNode left) {
  23.         this.left = left;
  24.     }
  25.  
  26.     public void setRight(TreeNode right) {
  27.         this.right = right;
  28.     }
  29.  
  30.     public T getValue() {
  31.         return this.value;
  32.     }
  33.  
  34.     public TreeNode getLeft() {
  35.         return this.left;
  36.     }
  37.  
  38.     public TreeNode getRight() {
  39.         return this.right;
  40.     }
  41.  
  42. } // end of class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement