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 void
add(T obj)
void
addAll(Iterable<T> objs)
void
addAll(Iterator<T> it)
void
clear()
Clears but keeps internal state allocatedvoid
close()
Clears and frees internal statevoid
forEach(BiConsumer<CoordI2,List<T>> action)
void
forEach(Consumer<? super T> action)
List<T>
get(HasPosition2 hasPosition2)
Iterator<T>
iterator()
void
remove(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:
close
in interfaceAutoCloseable
-
iterator
public Iterator<T> iterator()
- Specified by:
iterator
in interfaceIterable<T extends HasPosition2>
-
forEach
public void forEach(Consumer<? super T> action)
- Specified by:
forEach
in interfaceIterable<T extends HasPosition2>
-
forEach
public void forEach(BiConsumer<CoordI2,List<T>> action)
-
-