public class SpatialHashTable<T>
extends java.lang.Object
List<T> myElements; ... SpatialHashTable<T> table = new SpatialHashTable<>(spacing); List<Point3d> positions = new ArrayList<Point3d>(); for (T el : myElements) { positions.add(el.getPos()); } table.setup(positions,elements); // construct map Point3d mySearchPoint = new Point3d(0., 1., 2.); Iterator<List<T>> it = table.getCellsNear (searchPoint); while (it.hasNext()) { List<T> cell = it.next(); for (T el : cell) { el.doSomething(); } }
Constructor and Description |
---|
SpatialHashTable(double gridSpacing) |
Modifier and Type | Method and Description |
---|---|
java.util.List<T> |
getElsNear(Point3d pos)
Return an iterator which iterates through 27 cells.
|
void |
setup(java.util.List<? extends Point3d> positions,
java.util.List<? extends T> elements)
Replace the current map with a
new one generated from positions and elements.
|
public void setup(java.util.List<? extends Point3d> positions, java.util.List<? extends T> elements)
positions
- List of positions that determine the
position of each element in elementselements
- List of elements which will populate this
SpatialHashTable