Advertisement
Guest User

BinNode

a guest
Feb 22nd, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. // חוליה בינארית
  2. public class BinNode<T>
  3. {
  4. private T value;
  5. private BinNode<T> left;
  6. private BinNode<T> right;
  7.  
  8. public BinNode(T value)
  9. {
  10. this.value = value;
  11. this.left = null;
  12. this.right = null;
  13. }
  14.  
  15. public BinNode(BinNode<T> left, T value,BinNode<T> right)
  16. {
  17. this.value = value;
  18. this.left = left;
  19. this.right = right;
  20. }
  21.  
  22. public T getValue()
  23. {
  24. return this.value;
  25. }
  26.  
  27. public BinNode<T> getLeft()
  28. {
  29. return this.left;
  30. }
  31.  
  32. public BinNode<T> getRight()
  33. {
  34. return this.right;
  35. }
  36.  
  37. public void setValue(T value)
  38. {
  39. this.value = value;
  40. }
  41.  
  42. public void setLeft(BinNode<T> left)
  43. {
  44. this.left = left;
  45. }
  46.  
  47. public void setRight(BinNode<T> right)
  48. {
  49. this.right= right;
  50. }
  51.  
  52. public boolean hasLeft()
  53. {
  54. return (this.left != null);
  55. }
  56.  
  57. public boolean hasRight()
  58. {
  59. return (this.right != null);
  60. }
  61.  
  62. public String toString ()
  63. {
  64. return " ( " + this.left + " " + this.value + " " + this.right + " ) ";
  65. }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement