Package de.extio.spacecraft.shared.world
Class GridIndex2D<T extends HasPosition2>
- java.lang.Object
-
- de.extio.spacecraft.shared.world.GridIndex2D<T>
-
- All Implemented Interfaces:
AutoCloseable,Iterable<T>
public final class GridIndex2D<T extends HasPosition2> extends Object implements Iterable<T>, AutoCloseable
Implements a grid index that can query objects with dimension 1 very fast at the expense of memory consumption. Use QuadTree instead for very large grids or 2 dimensional objects.
-
-
Constructor Summary
Constructors Constructor Description GridIndex2D()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(T obj)voidaddAll(Iterable<T> objs)voidaddAll(Iterator<T> it)voidclear()Clears but keeps internal state allocatedvoidclose()Clears and frees internal statevoidforEach(BiConsumer<CoordI2,List<T>> action)voidforEach(Consumer<? super T> action)List<T>get(HasPosition2 hasPosition2)Iterator<T>iterator()voidremove(T obj)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
spliterator
-
-
-
-
Method Detail
-
add
public void add(T obj)
-
remove
public void remove(T obj)
-
get
public List<T> get(HasPosition2 hasPosition2)
-
clear
public void clear()
Clears but keeps internal state allocated
-
close
public void close()
Clears and frees internal state- Specified by:
closein interfaceAutoCloseable
-
iterator
public Iterator<T> iterator()
- Specified by:
iteratorin interfaceIterable<T extends HasPosition2>
-
forEach
public void forEach(Consumer<? super T> action)
- Specified by:
forEachin interfaceIterable<T extends HasPosition2>
-
forEach
public void forEach(BiConsumer<CoordI2,List<T>> action)
-
-