-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
565 additions
and
540 deletions.
There are no files selected for viewing
172 changes: 91 additions & 81 deletions
172
src/main/java/algorithms/orthogonalRangeSearching/RangeTreeNode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,86 +1,96 @@ | ||
package algorithms.orthogonalRangeSearching; | ||
|
||
/** | ||
* This class is the node class for building a range tree. | ||
* @param <T> Generic type of the node class | ||
*/ | ||
public class RangeTreeNode<T> { | ||
T val; | ||
int height; | ||
RangeTreeNode<T> left = null; | ||
RangeTreeNode<T> right = null; | ||
RangeTreeNode<T> parent = null; | ||
RangeTreeNode<T> yTree = null; | ||
|
||
public RangeTreeNode(T val) { | ||
this.val = val; | ||
} | ||
|
||
public RangeTreeNode(T val, RangeTreeNode<T> left, RangeTreeNode<T> right) { | ||
this.val = val; | ||
this.left = left; | ||
this.right = right; | ||
} | ||
|
||
public T getVal() { | ||
return this.val; | ||
} | ||
|
||
public int getHeight() { | ||
return this.height; | ||
} | ||
|
||
public RangeTreeNode<T> getLeft() { | ||
return this.left; | ||
} | ||
|
||
public RangeTreeNode<T> getRight() { | ||
return this.right; | ||
} | ||
|
||
public RangeTreeNode<T> getParent() { | ||
return this.parent; | ||
} | ||
|
||
public RangeTreeNode<T> getYTree() { | ||
return this.yTree; | ||
} | ||
|
||
public void setVal(T val) { | ||
this.val = val; | ||
} | ||
|
||
public void setLeft(RangeTreeNode<T> left) { | ||
this.left = left; | ||
} | ||
|
||
public void setRight(RangeTreeNode<T> right) { | ||
this.right = right; | ||
} | ||
|
||
public void setParent(RangeTreeNode<T> parent) { | ||
this.parent = parent; | ||
} | ||
|
||
public void setHeight(int height) { | ||
this.height = height; | ||
} | ||
|
||
public void setYTree(RangeTreeNode<T> yTree) { | ||
this.yTree = yTree; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object other) { | ||
if (other == this) { | ||
return true; | ||
} | ||
if (!(other instanceof RangeTreeNode)) { | ||
return false; | ||
} | ||
RangeTreeNode<T> node = (RangeTreeNode<T>) other; | ||
return this.val == node.val; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return String.valueOf(this.val); | ||
} | ||
private T val; | ||
private int height; | ||
private RangeTreeNode<T> left = null; | ||
private RangeTreeNode<T> right = null; | ||
private RangeTreeNode<T> parent = null; | ||
private RangeTreeNode<T> yTree = null; | ||
|
||
public RangeTreeNode(T val) { | ||
this.val = val; | ||
} | ||
|
||
/** | ||
* Constructor for range tree node | ||
* @param val value of node | ||
* @param left left child of node | ||
* @param right right child of node | ||
*/ | ||
public RangeTreeNode(T val, RangeTreeNode<T> left, RangeTreeNode<T> right) { | ||
this.val = val; | ||
this.left = left; | ||
this.right = right; | ||
} | ||
|
||
public T getVal() { | ||
return this.val; | ||
} | ||
|
||
public int getHeight() { | ||
return this.height; | ||
} | ||
|
||
public RangeTreeNode<T> getLeft() { | ||
return this.left; | ||
} | ||
|
||
public RangeTreeNode<T> getRight() { | ||
return this.right; | ||
} | ||
|
||
public RangeTreeNode<T> getParent() { | ||
return this.parent; | ||
} | ||
|
||
public RangeTreeNode<T> getYTree() { | ||
return this.yTree; | ||
} | ||
|
||
public void setVal(T val) { | ||
this.val = val; | ||
} | ||
|
||
public void setLeft(RangeTreeNode<T> left) { | ||
this.left = left; | ||
} | ||
|
||
public void setRight(RangeTreeNode<T> right) { | ||
this.right = right; | ||
} | ||
|
||
public void setParent(RangeTreeNode<T> parent) { | ||
this.parent = parent; | ||
} | ||
|
||
public void setHeight(int height) { | ||
this.height = height; | ||
} | ||
|
||
public void setYTree(RangeTreeNode<T> yTree) { | ||
this.yTree = yTree; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object other) { | ||
if (other == this) { | ||
return true; | ||
} | ||
if (!(other instanceof RangeTreeNode)) { | ||
return false; | ||
} | ||
RangeTreeNode<T> node = (RangeTreeNode<T>) other; | ||
return this.val == node.val; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return String.valueOf(this.val); | ||
} | ||
|
||
} |
Oops, something went wrong.