code: public int findClosest( P p , double maxDistance ) {
  		int best = -1;
  		bestDistance = maxDistance;
  
  		for( int i = 0; i < points.size(); i++ ) {
  			P c = points.get(i);
  
  			double distanceC = distance.distance(p,c);
  
  			if( distanceC <= bestDistance ) {
  				bestDistance = distanceC;
  				best = i;
  			}
  		}
  
  		return best;
  	}
docs: Finds the index of the point which has the smallest Euclidean distance to 'p' and is {@code <} maxDistance
  away.
  
  @param p A point.
  @param maxDistance The maximum distance (Euclidean squared) the neighbor can be.
  @return Index of the closest point.