/** * Associates the specified value with the specified coordinates in this * QuadTree. * * @param x x-coordinate where the specified value is to be associated. * @param y y-coordinate where the specified value is to be associated. * @param value value to be associated with the specified coordinates. * * @return true if insertion was successful and the data structure changed, * false otherwise. */ public boolean put(final double x, final double y, final T value) { if (!this.top.bounds.containsOrEquals(x, y)) { throw new IllegalArgumentException("cannot add a point at x=" + x + ", y=" + y + " with bounds " + this.top.bounds); } if (this.top.put(x, y, value)) { incrementSize(); return true; } return false; }
public boolean put(final double x, final double y, final T value) { return put(new Leaf<T>(x, y, value)); }
private void split() { this.northwest = new Node<>(this.bounds.minX, this.bounds.centerY, this.bounds.centerX, this.bounds.maxY); this.northeast = new Node<>(this.bounds.centerX, this.bounds.centerY, this.bounds.maxX, this.bounds.maxY); this.southeast = new Node<>(this.bounds.centerX, this.bounds.minY, this.bounds.maxX, this.bounds.centerY); this.southwest = new Node<>(this.bounds.minX, this.bounds.minY, this.bounds.centerX, this.bounds.centerY); this.hasChilds = true; if (this.leaves != null) { for (Leaf<T> leaf : this.leaves) { getChild(leaf.x, leaf.y).put(leaf); } this.leaves= null; } }