import edu.wlu.cs.levy.CG.KDTree;
import java.util.*;
-public class PointSet<V extends HasPoint> {
+public class PointSet<V extends HasPoint> implements Iterable<V> {
private /*final*/ KDTree kd = new KDTree(3);
private final double[] doubles = new double[3];
private HashMap<Point,V> exact = new HashMap<Point,V>();
+ public Iterator<V> iterator() {
+ return exact.values().iterator();
+ }
public void clear() {
kd = new KDTree(3);
}
+ public V get(Point p) {
+ return exact.get(p);
+ }
+
public void add(V v) {
+ V x = get(v.getPoint());
+ if (x != null && x.equals(v)) return;
Point p = v.getPoint();
doubles[0] = p.x;
doubles[1] = p.y;
}
public V nearest(Point p) {
+ if (exact.size()==0) return null;
Object[] results;
try {
doubles[0] = p.x;