Browse files

start on nearest neigbour search.

  • Loading branch information...
1 parent d28f1da commit 7ea5e1148e0d983fe53eb341e5bc3926e50c25e6 Stephen Nancekivell committed Apr 17, 2012
Showing with 30 additions and 1 deletion.
  1. +30 −1 src/main/java/info/stephenn/datastructures/KDTree.java
View
31 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;
@@ -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.