-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #54 from kaitinghh/branch-ORS
Orthogonal Range Searching
- Loading branch information
Showing
15 changed files
with
1,047 additions
and
2 deletions.
There are no files selected for viewing
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
96 changes: 96 additions & 0 deletions
96
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 |
---|---|---|
@@ -0,0 +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> { | ||
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.