@Test public void testRemove() { Random random = new Random(); Array<CollisionBox> collisionBoxs = new Array<CollisionBox>(); for(int i = 0; i < 1000; i++) { collisionBoxs.add(new CollisionBox(random.nextInt(96), random.nextInt(96), random.nextInt(32), random.nextInt(32))); } for(int i = 0; i < collisionBoxs.size; i++) { rootQuad.add(collisionBoxs.get(i)); Assert.assertEquals(i + 1, rootQuad.getElements().size); } for(int i = collisionBoxs.size - 1; i >= 0 ; i--) { Assert.assertEquals(i + 1, rootQuad.getElements().size); rootQuad.remove(collisionBoxs.get(i)); Assert.assertEquals(i, rootQuad.getElements().size); } }
@Override public boolean remove(T element) { if (element == null) return false; if (!this.intersects(element) && !this.contains(element)) { return false; } clearTotalElementsCache(); if (removeElement(element)) { return true; } if (topLeft == null) { return false; } return removeElementFromChild(element); }
RegionQuadTree extends PointQuadTree<T> { @Override public boolean remove(T element) { if (element == null) return false; if (!this.intersects(element) && !this.contains(element)) { return false; } clearTotalElementsCache(); if (removeElement(element)) { return true; } if (topLeft == null) { return false; } return removeElementFromChild(element); } }
RegionQuadTree extends PointQuadTree<T> { @Override public boolean remove(T element) { if (element == null) return false; if (!this.intersects(element) && !this.contains(element)) { return false; } clearTotalElementsCache(); if (removeElement(element)) { return true; } if (topLeft == null) { return false; } return removeElementFromChild(element); } RegionQuadTree(int elementLimit, int mergeWatermark, float x, float y, float width, float height);  RegionQuadTree(int elementLimit, float x, float y, float width, float height);  RegionQuadTree(RegionQuadTree<T> parent, float x, float y, float width, float height);  RegionQuadTree(float minimumQuadWidth, float minimumQuadHeight, int elementLimitPerQuad, int mergeWatermark,
			float x, float y, float width, float height); }
RegionQuadTree extends PointQuadTree<T> { @Override public boolean remove(T element) { if (element == null) return false; if (!this.intersects(element) && !this.contains(element)) { return false; } clearTotalElementsCache(); if (removeElement(element)) { return true; } if (topLeft == null) { return false; } return removeElementFromChild(element); } RegionQuadTree(int elementLimit, int mergeWatermark, float x, float y, float width, float height);  RegionQuadTree(int elementLimit, float x, float y, float width, float height);  RegionQuadTree(RegionQuadTree<T> parent, float x, float y, float width, float height);  RegionQuadTree(float minimumQuadWidth, float minimumQuadHeight, int elementLimitPerQuad, int mergeWatermark,
			float x, float y, float width, float height); @Override void debugRender(Graphics g); @Override void addAll(Array<T> elementsToAdd); @Override boolean add(T element); @Override boolean remove(T element); @Override void clear(); @Override void getElementsWithinArea(Array<T> result, Shape area); @Override void getElementsWithinArea(Array<T> result, Shape area, QuadTreeSearchDirection searchDirection); @Override Array<T> getElementsContainingArea(Shape area, boolean entirelyContained); @Override Array<T> getElementsContainingArea(Shape area, QuadTreeSearchDirection searchDirection, boolean entirelyContained); @Override void getElementsContainingArea(Array<T> result, Shape area, boolean entirelyContained); @Override void getElementsContainingArea(Array<T> result, Shape area, QuadTreeSearchDirection searchDirection, boolean entirelyContained); @Override void getElementsContainingPoint(Array<T> result, Point point); @Override void getElementsContainingPoint(Array<T> result, Point point, QuadTreeSearchDirection searchDirection); @Override void getElementsIntersectingLineSegment(Array<T> result, LineSegment lineSegment); @Override void getElementsIntersectingLineSegment(Array<T> result, LineSegment lineSegment, QuadTreeSearchDirection searchDirection); @Override Array<T> getElements(); @Override void getElements(Array<T> result); @Override int getTotalElements(); @Override void positionChanged(T moved); }
RegionQuadTree extends PointQuadTree<T> { @Override public boolean remove(T element) { if (element == null) return false; if (!this.intersects(element) && !this.contains(element)) { return false; } clearTotalElementsCache(); if (removeElement(element)) { return true; } if (topLeft == null) { return false; } return removeElementFromChild(element); } RegionQuadTree(int elementLimit, int mergeWatermark, float x, float y, float width, float height);  RegionQuadTree(int elementLimit, float x, float y, float width, float height);  RegionQuadTree(RegionQuadTree<T> parent, float x, float y, float width, float height);  RegionQuadTree(float minimumQuadWidth, float minimumQuadHeight, int elementLimitPerQuad, int mergeWatermark,
			float x, float y, float width, float height); @Override void debugRender(Graphics g); @Override void addAll(Array<T> elementsToAdd); @Override boolean add(T element); @Override boolean remove(T element); @Override void clear(); @Override void getElementsWithinArea(Array<T> result, Shape area); @Override void getElementsWithinArea(Array<T> result, Shape area, QuadTreeSearchDirection searchDirection); @Override Array<T> getElementsContainingArea(Shape area, boolean entirelyContained); @Override Array<T> getElementsContainingArea(Shape area, QuadTreeSearchDirection searchDirection, boolean entirelyContained); @Override void getElementsContainingArea(Array<T> result, Shape area, boolean entirelyContained); @Override void getElementsContainingArea(Array<T> result, Shape area, QuadTreeSearchDirection searchDirection, boolean entirelyContained); @Override void getElementsContainingPoint(Array<T> result, Point point); @Override void getElementsContainingPoint(Array<T> result, Point point, QuadTreeSearchDirection searchDirection); @Override void getElementsIntersectingLineSegment(Array<T> result, LineSegment lineSegment); @Override void getElementsIntersectingLineSegment(Array<T> result, LineSegment lineSegment, QuadTreeSearchDirection searchDirection); @Override Array<T> getElements(); @Override void getElements(Array<T> result); @Override int getTotalElements(); @Override void positionChanged(T moved);  }