Skip to content

Commit

Permalink
Merge pull request #2 from reimai/master
Browse files Browse the repository at this point in the history
fixed a bug with lPickSeeds peeking two nulls
  • Loading branch information
rweeks committed Feb 22, 2013
2 parents 25ebc2e + bfe98a5 commit e602eb0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/com/newbrightidea/util/RTree.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -530,6 +530,7 @@ private RTree<T>.Node[] lPickSeeds(LinkedList<Node> nn)
{ {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
RTree<T>.Node[] bestPair = new RTree.Node[2]; RTree<T>.Node[] bestPair = new RTree.Node[2];
boolean foundBestPair = false;
float bestSep = 0.0f; float bestSep = 0.0f;
for (int i = 0; i < numDims; i++) for (int i = 0; i < numDims; i++)
{ {
Expand Down Expand Up @@ -564,12 +565,13 @@ private RTree<T>.Node[] lPickSeeds(LinkedList<Node> nn)
bestPair[0] = nMaxLb; bestPair[0] = nMaxLb;
bestPair[1] = nMinUb; bestPair[1] = nMinUb;
bestSep = sep; bestSep = sep;
foundBestPair = true;
} }
} }
// In the degenerate case where all points are the same, the above // In the degenerate case where all points are the same, the above
// algorithm does not find a best pair. Just pick the first 2 // algorithm does not find a best pair. Just pick the first 2
// children. // children.
if ( bestPair == null ) if ( !foundBestPair )
{ {
bestPair = new RTree.Node[] { nn.get(0), nn.get(1) }; bestPair = new RTree.Node[] { nn.get(0), nn.get(1) };
} }
Expand Down

0 comments on commit e602eb0

Please sign in to comment.