Skip to content

Commit

Permalink
start on nearest neigbour search.
Browse files Browse the repository at this point in the history
  • Loading branch information
stephennancekivell committed Apr 17, 2012
1 parent d28f1da commit 7ea5e11
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion src/main/java/info/stephenn/datastructures/KDTree.java
@@ -1,6 +1,5 @@
package info.stephenn.datastructures;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
Expand Down Expand Up @@ -51,5 +50,35 @@ public Node getChild(List<Integer> lookup) {
return null; // doesnt exist
}
}

public Node getNearest(List<Integer> lookup){
return null;
//TODO
}

public Node fildClosest(Node currentBest, List<Integer> toKeys){
if (currentBest == null) return this;


return null;
}

public int squaredDistanceTo(Node n){
assert(n.keys.size()== this.keys.size());
int distance =0;
for (int i=0; i < n.keys.size(); i++){
int diff = (keys.get(i)-n.keys.get(i));
distance += diff * diff;
}
return distance;
}

public static class point{
public final int[] values;
public point(int[] _values){
this.values = _values;
}
}
}

}

0 comments on commit 7ea5e11

Please sign in to comment.