(Node x, Point2D p, boolean isXPartition, double xmin, double ymin, double xmax,
double ymax)
| 41 | } |
| 42 | |
| 43 | private Node put(Node x, Point2D p, boolean isXPartition, double xmin, double ymin, double xmax, |
| 44 | double ymax) { |
| 45 | if (x == null) return new Node(p, new RectHV(xmin, ymin, xmax, ymax)); |
| 46 | int cmp = isXPartition ? Double.compare(p.x(), x.p.x()) |
| 47 | : Double.compare(p.y(), x.p.y()); |
| 48 | |
| 49 | if (cmp < 0) { |
| 50 | if (isXPartition) xmax = x.p.x(); |
| 51 | else ymax = x.p.y(); |
| 52 | x.left = put(x.left, p, !isXPartition, xmin, ymin, xmax, ymax); |
| 53 | } |
| 54 | else { |
| 55 | if (isXPartition) xmin = x.p.x(); |
| 56 | else ymin = x.p.y(); |
| 57 | x.right = put(x.right, p, !isXPartition, xmin, ymin, xmax, ymax); |
| 58 | } |
| 59 | return x; |
| 60 | } |
| 61 | |
| 62 | // does the set contain point p? |
| 63 | public boolean contains(Point2D p) { |
no outgoing calls
no test coverage detected