rtree.init(props);
}
+ public void add(V v) { insert(v); }
public void insert(V v) {
int id = lowid++;
idToV.put(id, v);
}
public void remove(V v) {
- int id = vToId.get(v);
+ Integer idi = vToId.get(v);
+ if (idi==null) return;
+ int id = idi;
idToV.remove(id);
vToId.remove(v);
rtree.delete(new com.infomatiq.jsi.Rectangle(v.getMinX(), v.getMinY(), v.getMinZ(),
id);
}
-
+ // gross...
V found = null;
-
private IntProcedure finder = new IntProcedure() {
public boolean execute(int id) {
found = idToV.get(id);
found = null;
return ret;
}
+
+ Visitor<V> visitor = null;
+ private IntProcedure searcher = new IntProcedure() {
+ public boolean execute(int id) {
+ V v = idToV.get(id);
+ visitor.visit(v);
+ return true;
+ }
+ };
+ public void range(HasBoundingBox v, Visitor vis) {
+ visitor = vis;
+ rtree.intersects(new com.infomatiq.jsi.Rectangle(v.getMinX(), v.getMinY(), v.getMinZ(),
+ v.getMaxX(), v.getMaxY(), v.getMaxZ()),
+ searcher);
+ visitor = null;
+ }
+
}