(RectHV rect)
| 52 | |
| 53 | // all points that are inside the rectangle (or on the boundary) |
| 54 | public Iterable<Point2D> range(RectHV rect) { |
| 55 | if (rect == null) throw new IllegalArgumentException(); |
| 56 | ArrayList<Point2D> arrayList = new ArrayList<>(); |
| 57 | for (Point2D p : treeSet) |
| 58 | if (rect.contains(p)) arrayList.add(p); |
| 59 | return arrayList; |
| 60 | } |
| 61 | |
| 62 | // a nearest neighbor in the set to point p; null if the set is empty |
| 63 | public Point2D nearest(Point2D p) { |