@Test public void testGetTotalElements() { rootQuad.add(box1); Assert.assertEquals(1, rootQuad.getTotalElements()); rootQuad.add(box2); Assert.assertEquals(2, rootQuad.getTotalElements()); rootQuad.add(box3); Assert.assertEquals(3, rootQuad.getTotalElements()); rootQuad.remove(box2); Assert.assertEquals(2, rootQuad.getTotalElements()); rootQuad.add(box4); Assert.assertEquals(3, rootQuad.getTotalElements()); rootQuad.add(box2); Assert.assertEquals(4, rootQuad.getTotalElements()); rootQuad.add(new CollisionBox(48, 48, 32, 32)); Assert.assertEquals(5, rootQuad.getTotalElements()); rootQuad.add(new CollisionBox(12, 48, 8, 8)); Assert.assertEquals(6, rootQuad.getTotalElements()); }
@Override public int getTotalElements() { if (totalElementsCache >= 0) { return totalElementsCache; } totalElementsCache = 0; lock.lockRead(); if (topLeft != null) { totalElementsCache = topLeft.getTotalElements(); totalElementsCache += topRight.getTotalElements(); totalElementsCache += bottomLeft.getTotalElements(); totalElementsCache += bottomRight.getTotalElements(); } totalElementsCache += elements.size; lock.unlockRead(); return totalElementsCache; }
ConcurrentRegionQuadTree extends ConcurrentPointQuadTree<T> { @Override public int getTotalElements() { if (totalElementsCache >= 0) { return totalElementsCache; } totalElementsCache = 0; lock.lockRead(); if (topLeft != null) { totalElementsCache = topLeft.getTotalElements(); totalElementsCache += topRight.getTotalElements(); totalElementsCache += bottomLeft.getTotalElements(); totalElementsCache += bottomRight.getTotalElements(); } totalElementsCache += elements.size; lock.unlockRead(); return totalElementsCache; } }
ConcurrentRegionQuadTree extends ConcurrentPointQuadTree<T> { @Override public int getTotalElements() { if (totalElementsCache >= 0) { return totalElementsCache; } totalElementsCache = 0; lock.lockRead(); if (topLeft != null) { totalElementsCache = topLeft.getTotalElements(); totalElementsCache += topRight.getTotalElements(); totalElementsCache += bottomLeft.getTotalElements(); totalElementsCache += bottomRight.getTotalElements(); } totalElementsCache += elements.size; lock.unlockRead(); return totalElementsCache; } ConcurrentRegionQuadTree(int elementLimit, int mergeWatermark, float x, float y, float width, float height);  ConcurrentRegionQuadTree(int elementLimit, float x, float y, float width, float height);  ConcurrentRegionQuadTree(ConcurrentRegionQuadTree<T> parent, float x, float y, float width, float height);  ConcurrentRegionQuadTree(float minimumQuadWidth, float minimumQuadHeight, int elementLimitPerQuad,
			int mergeWatermark, float x, float y, float width, float height); }
ConcurrentRegionQuadTree extends ConcurrentPointQuadTree<T> { @Override public int getTotalElements() { if (totalElementsCache >= 0) { return totalElementsCache; } totalElementsCache = 0; lock.lockRead(); if (topLeft != null) { totalElementsCache = topLeft.getTotalElements(); totalElementsCache += topRight.getTotalElements(); totalElementsCache += bottomLeft.getTotalElements(); totalElementsCache += bottomRight.getTotalElements(); } totalElementsCache += elements.size; lock.unlockRead(); return totalElementsCache; } ConcurrentRegionQuadTree(int elementLimit, int mergeWatermark, float x, float y, float width, float height);  ConcurrentRegionQuadTree(int elementLimit, float x, float y, float width, float height);  ConcurrentRegionQuadTree(ConcurrentRegionQuadTree<T> parent, float x, float y, float width, float height);  ConcurrentRegionQuadTree(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> elements); @Override boolean add(T element); @Override void removeAll(Array<T> elementsToRemove); @Override boolean remove(T element); @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); }
ConcurrentRegionQuadTree extends ConcurrentPointQuadTree<T> { @Override public int getTotalElements() { if (totalElementsCache >= 0) { return totalElementsCache; } totalElementsCache = 0; lock.lockRead(); if (topLeft != null) { totalElementsCache = topLeft.getTotalElements(); totalElementsCache += topRight.getTotalElements(); totalElementsCache += bottomLeft.getTotalElements(); totalElementsCache += bottomRight.getTotalElements(); } totalElementsCache += elements.size; lock.unlockRead(); return totalElementsCache; } ConcurrentRegionQuadTree(int elementLimit, int mergeWatermark, float x, float y, float width, float height);  ConcurrentRegionQuadTree(int elementLimit, float x, float y, float width, float height);  ConcurrentRegionQuadTree(ConcurrentRegionQuadTree<T> parent, float x, float y, float width, float height);  ConcurrentRegionQuadTree(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> elements); @Override boolean add(T element); @Override void removeAll(Array<T> elementsToRemove); @Override boolean remove(T element); @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);  }