Created
April 25, 2010 18:04
-
-
Save lxmonk/378583 to your computer and use it in GitHub Desktop.
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
protected MyObject overlapSearch(Comparable start,Comparable end) { | |
MyObject leftSubTreeOverlap, rightSubTreeOverlap; | |
leftSubTreeOverlap = rightSubTreeOverlap = null; | |
if (this.getData().overlap(start, end)) { | |
return this.getData(); | |
} | |
else if ((((Integer) this.getData().getKeyData()).compareTo((Integer) end) <= 0) | |
&& (this.getRight() != null)) { | |
rightSubTreeOverlap = this.getRight().overlapSearch(start, end); | |
return rightSubTreeOverlap; | |
} | |
if (this.getLeft() != null && this.getLeft().getMax().compareTo(start) >= 0) { | |
leftSubTreeOverlap = this.getLeft().overlapSearch(start, end); | |
if (leftSubTreeOverlap != null) { | |
return leftSubTreeOverlap; | |
} | |
} | |
return null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment