Package de.extio.spacecraft.shared.world
Interface SpatialIndex2D<T extends SpatialIndex2Capable>
-
- All Superinterfaces:
AutoCloseable
,Iterable<T>
- All Known Implementing Classes:
BinarySearchIndex2D
,HashBucketIndex2D
,LinearSearchIndex2D
,QuadTree
public interface SpatialIndex2D<T extends SpatialIndex2Capable> extends Iterable<T>, AutoCloseable
Spatial indexes are used for spatial queries. See also QuadTree
-
-
Field Summary
Fields Modifier and Type Field Description static AtomicLong
SESSION
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
add(T obj)
Adds an object to the indexvoid
clear()
Clears but keeps internal state allocated.void
close()
Clears and frees internal statedefault void
executeAt(CoordI2 position, Consumer<T> consumer)
Executes a consumer for all objects at a given position.void
executeAt(CoordI2 position, Consumer<T> consumer, Predicate<T> filter)
Executes a consumer for all objects at a given position.default List<T>
find(CoordI2 position, CoordI2 dimension)
Queries all object intersecting with a given areaList<T>
find(CoordI2 position, CoordI2 dimension, Predicate<T> filter)
Queries all object intersecting with a given area.default List<T>
find(HasPositionAndDimension2 hasPositionAndDimension2)
Queries all object intersecting with a given areadefault Collection<T>
find(RectI2 rect)
Queries all object intersecting with a given areadefault T
findFirstAt(CoordI2 position)
Returns the first object at a given positionT
findFirstAt(CoordI2 position, Predicate<T> filter)
Returns the first object at a given position.void
move(T obj, CoordI2 oldPosition, CoordI2 oldDimension)
Moves an indexed object to a new location.void
remove(T obj)
Removes an object from the index-
Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
-
-
-
Field Detail
-
SESSION
static final AtomicLong SESSION
-
-
Method Detail
-
add
void add(T obj)
Adds an object to the index
-
remove
void remove(T obj)
Removes an object from the index
-
move
void move(T obj, CoordI2 oldPosition, CoordI2 oldDimension)
Moves an indexed object to a new location. Implementations are usually faster than doing separate remove() and add() operations
-
find
default Collection<T> find(RectI2 rect)
Queries all object intersecting with a given area
-
find
default List<T> find(HasPositionAndDimension2 hasPositionAndDimension2)
Queries all object intersecting with a given area
-
find
default List<T> find(CoordI2 position, CoordI2 dimension)
Queries all object intersecting with a given area
-
find
List<T> find(CoordI2 position, CoordI2 dimension, Predicate<T> filter)
Queries all object intersecting with a given area. Objects can be pre-filtered which is usually faster than returning them first and then filter in your own code.
-
findFirstAt
T findFirstAt(CoordI2 position, Predicate<T> filter)
Returns the first object at a given position. Objects can be pre-filtered which is usually faster than returning them first and then filter in your own code.
-
executeAt
default void executeAt(CoordI2 position, Consumer<T> consumer)
Executes a consumer for all objects at a given position.
-
executeAt
void executeAt(CoordI2 position, Consumer<T> consumer, Predicate<T> filter)
Executes a consumer for all objects at a given position. Objects can be pre-filtered which is usually faster than returning them first and then filter in your own code.
-
close
void close()
Clears and frees internal state- Specified by:
close
in interfaceAutoCloseable
-
clear
void clear()
Clears but keeps internal state allocated. Optimization for re-use.
-
-