/* * Linear neighbors search * * CSI2510 Algorithmes et Structures de Donnees * www.uottawa.ca * * Robert Laganiere, 2022 * */ import java.util.List; import java.util.ArrayList; public class NearestNeighbors { protected java.util.List points; // construct with list of points public NearestNeighbors(java.util.List points) { this.points= points; } // gets the neighbors of p (at a distance less than eps) public List rangeQuery(Point3D p, double eps) { // empty list to contain the neighbors List neighbors= new ArrayList(); for (Point3D point: points) { if (p.distance(point) < eps) { neighbors.add(point); } } return neighbors; } }