import edu.wlu.cs.levy.CG.KDTree;
/* here I made a very simple class that I use in the main program. I had to put it here in a .java file so I could use the template syntax KDTree<foo> ... */

class PointTree {
  KDTree<double[]> kdt = new KDTree<double[]>(2);

  public void addPoint(double x, double y) {
    double[] dd = {x,y};
    try {
      kdt.insert(dd,dd);
    } catch(Exception e) {}
  }
  public double[] getNearestPoint(double[] dd) {
    double[] ret = {0,0};
    try {
      ret = (kdt.nearest(dd));
    } catch(Exception e) { System.out.println("Wrong number of keys provide"); System.exit(0); }
    return ret;
  }
  public void removePoint(double[] dd) {
    try {
      kdt.delete(dd);
    }catch(Exception e) { System.out.println("Wrong number of keys provided. xxx"); System.exit(0); }
  }
  public int size() {
    return kdt.size();
  }
}

