T
- The value type of the DoubleOctreepublic class DoubleOctree<T> extends Object implements DoubleOctreeIterable<T>
Octree
to store data at double x/y/z coordinates, instead of int.
This is done by giving each 1x1x1 area a linked list of entries stored there.
If a lot of values are stored inside single 1x1x1 areas, this container is not recommended.Modifier and Type | Class and Description |
---|---|
static class |
DoubleOctree.Entry<T>
Immutable entry in a Double Octree.
|
Constructor and Description |
---|
DoubleOctree() |
Modifier and Type | Method and Description |
---|---|
void |
add(double x,
double y,
double z,
T value)
Adds a new entry at the specified coordinates
|
void |
addEntry(DoubleOctree.Entry<? extends T> value)
Puts a new entry into this tree.
|
DoubleOctreeIterable<T> |
block(IntVector3 block)
Gets a view of the contents of this tree that lay inside a single 1x1x1 block area.
|
void |
clear()
Clears all the contents of this Double Octree, freeing all memory associated with it.
|
boolean |
contains(double x,
double y,
double z,
Object value)
Checks whether a value is stored at the coordinates specified.
|
boolean |
containsEntry(DoubleOctree.Entry<?> entry)
Checks whether the value stored at the coordinates of an entry,
match the value of the entry.
|
DoubleOctreeIterable<T> |
cuboid(IntVector3 min,
IntVector3 max)
Gets a view of the contents of this tree that lay inside a cuboid area.
|
Collection<T> |
get(double x,
double y,
double z)
Gets the values stored at the specified coordinates.
|
DoubleOctreeIterator<T> |
iterator() |
boolean |
move(double oldX,
double oldY,
double oldZ,
T value,
double newX,
double newY,
double newZ)
Moves an entry from the old position to a new position as efficiently as possible.
|
boolean |
move(double oldX,
double oldY,
double oldZ,
T oldValue,
double newX,
double newY,
double newZ,
T newValue)
Moves an entry from the old position to a new position as efficiently as possible.
|
boolean |
moveEntry(DoubleOctree.Entry<? extends T> oldEntry,
DoubleOctree.Entry<? extends T> newEntry)
Moves an entry from the old position to a new position as efficiently as possible.
|
boolean |
remove(double x,
double y,
double z,
Object value)
Removes an entry stored at the coordinates specified, returning the entry that was
removed.
|
boolean |
removeEntry(DoubleOctree.Entry<?> entry)
Removes an entry stored inside this octree.
|
Collection<T> |
values()
Gets an unmodifiable view of all the values inside this tree
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
public void clear()
public DoubleOctreeIterator<T> iterator()
public Collection<T> values()
public DoubleOctreeIterable<T> cuboid(IntVector3 min, IntVector3 max)
min
- coordinates of the cuboid (inclusive)max
- coordinates of the cuboid (inclusive)public DoubleOctreeIterable<T> block(IntVector3 block)
block
- coordinatepublic boolean contains(double x, double y, double z, Object value)
x
- The X-coordinatey
- The Y-coordinatez
- The Z-coordinatevalue
- The value expected to be stored herepublic Collection<T> get(double x, double y, double z)
x
- The X-coordinatey
- The Y-coordinatez
- The Z-coordinatepublic void add(double x, double y, double z, T value)
x
- The X-coordinatey
- The Y-coordinatez
- The Z-coordinatevalue
- The value to storepublic boolean remove(double x, double y, double z, Object value)
x
- The X-coordinatey
- The Y-coordinatez
- The Z-coordinatevalue
- The value of the entry to removepublic boolean move(double oldX, double oldY, double oldZ, T oldValue, double newX, double newY, double newZ, T newValue)
oldX
- The X-coordinate of the old positionoldY
- The Y-coordinate of the old positionoldZ
- The Z-coordinate of the old positionoldValue
- The value stored at the old positionnewX
- The X-coordinate of the desired new positionnewY
- The Y-coordinate of the desired new positionnewZ
- The Z-coordinate of the desired new positionnewValue
- The value to store at the new position#moveEntry(Entry, Entry)}
public boolean move(double oldX, double oldY, double oldZ, T value, double newX, double newY, double newZ)
oldX
- The X-coordinate of the old positionoldY
- The Y-coordinate of the old positionoldZ
- The Z-coordinate of the old positionvalue
- The value stored at the old position that will be moved to a new positionnewX
- The X-coordinate of the desired new positionnewY
- The Y-coordinate of the desired new positionnewZ
- The Z-coordinate of the desired new position#moveEntry(Entry, Entry)}
public boolean containsEntry(DoubleOctree.Entry<?> entry)
Object.equals(Object)
method
is used to perform the final check. If the value of the entry
and of what is stored are both null, the two are assumed equal.entry
- The entry to findpublic void addEntry(DoubleOctree.Entry<? extends T> value)
value
- public boolean removeEntry(DoubleOctree.Entry<?> entry)
entry
- The entry to removepublic boolean moveEntry(DoubleOctree.Entry<? extends T> oldEntry, DoubleOctree.Entry<? extends T> newEntry)
oldEntry
- to replace, null to only add a new entrynewEntry
- to replace oldEntry with, null to remove the old entryCopyright © 2019. All rights reserved.