@Test public void testAddAll() { int totalElements = 100; Random random = new Random(); Array<CollisionBox> rects = new Array<CollisionBox>(); long startTime = System.nanoTime(); for(int i = 0; i < totalElements; i++) { rects.add(new CollisionBox(random.nextInt(96), random.nextInt(96), 32f, 32f)); } rects.add(new CollisionBox(-4f, -4f, 32f, 32f)); rootQuad.addAll(rects); long duration = System.nanoTime() - startTime; System.out.println("Took " + duration + "ns to add " + totalElements + " elements in bulk to " + RegionQuadTree.class.getSimpleName()); Assert.assertEquals(rects.size, rootQuad.getTotalElements()); }
@Override public void addAll(Array<T> elementsToAdd) { if (elementsToAdd == null || elementsToAdd.size == 0) { return; } clearTotalElementsCache(); Array<T> elementsWithinQuad = new Array<T>(); for (T element : elementsToAdd) { if (this.contains(element) || this.intersects(element)) { elementsWithinQuad.add(element); } } for (T element : elementsWithinQuad) { if (topLeft == null) { addElement(element); continue; } if (addElementToChild(element)) { continue; } addElement(element); } }
RegionQuadTree extends PointQuadTree<T> { @Override public void addAll(Array<T> elementsToAdd) { if (elementsToAdd == null || elementsToAdd.size == 0) { return; } clearTotalElementsCache(); Array<T> elementsWithinQuad = new Array<T>(); for (T element : elementsToAdd) { if (this.contains(element) || this.intersects(element)) { elementsWithinQuad.add(element); } } for (T element : elementsWithinQuad) { if (topLeft == null) { addElement(element); continue; } if (addElementToChild(element)) { continue; } addElement(element); } } }
RegionQuadTree extends PointQuadTree<T> { @Override public void addAll(Array<T> elementsToAdd) { if (elementsToAdd == null || elementsToAdd.size == 0) { return; } clearTotalElementsCache(); Array<T> elementsWithinQuad = new Array<T>(); for (T element : elementsToAdd) { if (this.contains(element) || this.intersects(element)) { elementsWithinQuad.add(element); } } for (T element : elementsWithinQuad) { if (topLeft == null) { addElement(element); continue; } if (addElementToChild(element)) { continue; } addElement(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 void addAll(Array<T> elementsToAdd) { if (elementsToAdd == null || elementsToAdd.size == 0) { return; } clearTotalElementsCache(); Array<T> elementsWithinQuad = new Array<T>(); for (T element : elementsToAdd) { if (this.contains(element) || this.intersects(element)) { elementsWithinQuad.add(element); } } for (T element : elementsWithinQuad) { if (topLeft == null) { addElement(element); continue; } if (addElementToChild(element)) { continue; } addElement(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 void addAll(Array<T> elementsToAdd) { if (elementsToAdd == null || elementsToAdd.size == 0) { return; } clearTotalElementsCache(); Array<T> elementsWithinQuad = new Array<T>(); for (T element : elementsToAdd) { if (this.contains(element) || this.intersects(element)) { elementsWithinQuad.add(element); } } for (T element : elementsWithinQuad) { if (topLeft == null) { addElement(element); continue; } if (addElementToChild(element)) { continue; } addElement(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);  }