public Leaf<T> nextLeaf(final Leaf<T> currentLeaf) { MutableLeaf<T> nextLeaf = new MutableLeaf<>(null); nextLeaf(currentLeaf, nextLeaf); return nextLeaf.value; }
/** * Gets the object closest to x/y * * @param x easting, left-right location, longitude * @param y northing, up-down location, latitude * @return the object found closest to x/y */ public T getClosest(final double x, final double y) { return this.top.get(x, y, new MutableDouble(Double.POSITIVE_INFINITY)); }
private void stepInto(Node node, double x, double y, double r_min, double r_max, Collection<T> values) { double minDistance = node.bounds.calcDistance(x, y); double maxDistance = node.bounds.calcMaxDistance(x, y); if(minDistance <= r_max && maxDistance >= r_min) { node.get(x, y, r_min, r_max, values); } }
/** * Convenience method to create XML Attributes written by startTag() */ protected static Tuple<String, String> createTuple(String one, String two){ return new Tuple<>(one, two); } /**
public void testAdd_Null() { PseudoRemovePriorityQueue<Integer> pq = new PseudoRemovePriorityQueue<Integer>(10); try { pq.add(null, 1.0); fail("missing NullPointerException."); } catch (NullPointerException e) { log.info("catched expected exception. ", e); } assertEquals(0, pq.size()); assertEquals(0, iteratorElementCount(pq.iterator())); }
/** * retrieve cell for a given coordinate. Cell with closest centroid will be returne * * @param coordinate coordinate within a cell * @return Cell with closest centroid. */ public Cell<T> getCell(Coordinate coordinate) { return quadTree.getClosest(coordinate.x, coordinate.y); }
@Test public void testGetDistance_fromOutsideExtent() { QuadTree<String> qt = getTestTree(); assertContains(new String[] {"100.0, 0.0"}, qt.getDisk(160.0, 0, 60.1)); // E assertContains(new String[] {"15.0, 15.0", "15.0, 15.0 B"}, qt.getDisk(15.0, 160, 145.1)); // N assertContains(new String[] {"-15.0, 0.0"}, qt.getDisk(-60.0, 0, 45.1)); // W assertContains(new String[] {"100.0, 0.0"}, qt.getDisk(100.0, -60, 60.1)); // S }
/** * Gets all objects inside the specified area. Objects on the border of * the area are not included. * * @param minX The minimum left-right location, longitude * @param minY The minimum up-down location, latitude * @param maxX The maximum left-right location, longitude * @param maxY The maximum up-down location, latitude * @param values1 A collection to store the found objects in. * @return The objects found within the area. */ public Collection<T> getRectangle(final double minX, final double minY, final double maxX, final double maxY, final Collection<T> values1) { return getRectangle(new Rect(minX, minY, maxX, maxY), values1); }
/** * Executes executor on all objects inside the rectangle (minX,minY):(maxX,maxY) * * @param minX The minimum left-right location, longitude * @param minY The minimum up-down location, latitude * @param maxX The maximum left-right location, longitude * @param maxY The maximum up-down location, latitude * @param executor is executed on the fitting objects * @return the count of objects found within the rectangle. */ public int execute(final double minX, final double minY, final double maxX, final double maxY, final Executor<T> executor) { return execute(new Rect(minX, minY, maxX, maxY), executor); }
/** * Allow replacing the RouterPriorityQueue. */ @SuppressWarnings("static-method") /*package*/ RouterPriorityQueue<? extends Node> createRouterPriorityQueue() { return new PseudoRemovePriorityQueue<>(500); }
/** * retrieve all cells * @return all cells of the grid */ public Collection<Cell<T>> getCells() { return quadTree.values(); }
public void setTranslateY(double translateY) { this.viewBounds = new Rect(viewBounds.minX, viewBounds.minY + (translateY - this.translateY), viewBounds.maxX, viewBounds.maxY + (translateY - this.translateY)); this.translateY = translateY; } }
/** * Sets a new top node in case the extremities from the c'tor are not * good anymore, it also clear the QuadTree * @param minX The smallest x coordinate expected * @param minY The smallest y coordinate expected * @param maxX The largest x coordinate expected * @param maxY The largest y coordinate expected */ protected void setTopNode(final double minX, final double minY, final double maxX, final double maxY) { this.top = new Node<OTFDataWriter>(minX, minY, maxX, maxY); }
/** * Gets all objects inside the specified boundary. Objects on the border of the * boundary are not included. * * @param bounds The bounds of the area of interest. * @param values1 A collection to store the found objects in. * @return The objects found within the area. */ public Collection<T> getRectangle(final Rect bounds, final Collection<T> values1) { return this.top.get(bounds, values1); }
@Override public boolean containsAll(Collection<?> c) { for (Object o : c) { boolean isPartOf = this.contains(o); if (!isPartOf) { return false; } } return true; }
/** Clear the QuadTree. */ public void clear() { this.top.clear(); this.size = 0; this.modCount++; }
private Tuple<Double, Double> getTimeOfOperationFromTimeSlots(int startSlot, int endSlot){ // convert slots to time double startTime = ((double) startSlot) * this.timeBinSize; double endTime = ((double) endSlot + 1) * this.timeBinSize; return new Tuple<>(startTime, endTime); } }