Package com.io7m.jspatial.implementation
Class OctTreeD<T>
- java.lang.Object
-
- com.io7m.jspatial.implementation.OctTreeD<T>
-
- Type Parameters:
T- The precise type of tree objects
- All Implemented Interfaces:
OctTreeDType<T>,OctTreeReadableDType<T>,OctTreeReadableType
public final class OctTreeD<T> extends java.lang.Object implements OctTreeDType<T>
Default implementation of theOctTreeDTypeinterface.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classOctTreeD.Octant
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description com.io7m.jregions.core.unparameterized.volumes.VolumeDbounds()voidclear()Remove all objects from the tree.voidcontainedBy(com.io7m.jregions.core.unparameterized.volumes.VolumeD volume, java.util.Set<T> items)Returns all objects in the tree that are completely contained withinvolume, saving the results toitems.booleancontains(T item)Determine whether or not the object has already been inserted into the tree.static <T> OctTreeDType<T>create(OctTreeConfigurationD config)Create a new empty tree with the given bounds.booleanequals(java.lang.Object o)inthashCode()booleaninsert(T item, com.io7m.jregions.core.unparameterized.volumes.VolumeD item_bounds)Insert the objectiteminto the octtree.<C> voiditerateOctants(C context, OctTreeOctantIterationDType<T,C> f)Iterate over all octants within the tree.<U> OctTreeDType<U>map(java.util.function.BiFunction<T,com.io7m.jregions.core.unparameterized.volumes.VolumeD,U> f)Applyfto each element of the tree.voidoverlappedBy(com.io7m.jregions.core.unparameterized.volumes.VolumeD volume, java.util.Set<T> items)Returns all objects in the tree that are overlappedvolume, saving the results toitems.voidraycast(Ray3D ray, java.util.SortedSet<OctTreeRaycastResultD<T>> items)Returns all objects that are intersected by the given ray.booleanremove(T item)Remove the objectitemfrom the octtree.longsize()voidtrim()Trim all empty quadrants from the tree.com.io7m.jregions.core.unparameterized.volumes.VolumeDvolumeFor(T item)-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.io7m.jspatial.api.octtrees.OctTreeReadableType
isEmpty
-
-
-
-
Method Detail
-
create
public static <T> OctTreeDType<T> create(OctTreeConfigurationD config)
Create a new empty tree with the given bounds.- Type Parameters:
T- The type of objects contained within the tree- Parameters:
config- The tree configuration- Returns:
- A new tree
-
trim
public void trim()
Description copied from interface:OctTreeDTypeTrim all empty quadrants from the tree.- Specified by:
trimin interfaceOctTreeDType<T>
-
size
public long size()
- Specified by:
sizein interfaceOctTreeReadableType- Returns:
- The number of elements in the tree
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
bounds
public com.io7m.jregions.core.unparameterized.volumes.VolumeD bounds()
- Specified by:
boundsin interfaceOctTreeReadableDType<T>- Returns:
- The tree bounds
-
insert
public boolean insert(T item, com.io7m.jregions.core.unparameterized.volumes.VolumeD item_bounds)
Description copied from interface:OctTreeDTypeInsert the object
iteminto the octtree.The function returns
falseif the object could not be inserted for any reason (perhaps due to being too large).- Specified by:
insertin interfaceOctTreeDType<T>- Parameters:
item- The object to insertitem_bounds- The object's bounds- Returns:
trueif the object was inserted
-
contains
public boolean contains(T item)
Description copied from interface:OctTreeReadableDTypeDetermine whether or not the object has already been inserted into the tree.- Specified by:
containsin interfaceOctTreeReadableDType<T>- Parameters:
item- The object- Returns:
trueiff the object is in the tree
-
remove
public boolean remove(T item)
Description copied from interface:OctTreeDTypeRemove the object
itemfrom the octtree.The function returns
falseif the object could not be removed for any reason (perhaps due to not being in the tree in the first place).- Specified by:
removein interfaceOctTreeDType<T>- Parameters:
item- The object to remove- Returns:
trueif the object was removed
-
clear
public void clear()
Description copied from interface:OctTreeDTypeRemove all objects from the tree.- Specified by:
clearin interfaceOctTreeDType<T>
-
map
public <U> OctTreeDType<U> map(java.util.function.BiFunction<T,com.io7m.jregions.core.unparameterized.volumes.VolumeD,U> f)
Description copied from interface:OctTreeDTypeApplyfto each element of the tree.- Specified by:
mapin interfaceOctTreeDType<T>- Specified by:
mapin interfaceOctTreeReadableDType<T>- Type Parameters:
U- The type of result elements- Parameters:
f- A mapping function- Returns:
- A new tree
-
iterateOctants
public <C> void iterateOctants(C context, OctTreeOctantIterationDType<T,C> f)Description copied from interface:OctTreeReadableDTypeIterate over all octants within the tree.- Specified by:
iterateOctantsin interfaceOctTreeReadableDType<T>- Type Parameters:
C- The type of context values- Parameters:
context- A contextual value passed toff- An iteration function
-
volumeFor
public com.io7m.jregions.core.unparameterized.volumes.VolumeD volumeFor(T item)
- Specified by:
volumeForin interfaceOctTreeReadableDType<T>- Parameters:
item- The item- Returns:
- The bounding volume that was specified for
item
-
containedBy
public void containedBy(com.io7m.jregions.core.unparameterized.volumes.VolumeD volume, java.util.Set<T> items)Description copied from interface:OctTreeReadableDTypeReturns all objects in the tree that are completely contained withinvolume, saving the results toitems.- Specified by:
containedByin interfaceOctTreeReadableDType<T>- Parameters:
volume- The volume to examineitems- The returned items
-
overlappedBy
public void overlappedBy(com.io7m.jregions.core.unparameterized.volumes.VolumeD volume, java.util.Set<T> items)Description copied from interface:OctTreeReadableDTypeReturns all objects in the tree that are overlappedvolume, saving the results toitems.- Specified by:
overlappedByin interfaceOctTreeReadableDType<T>- Parameters:
volume- The volume to examineitems- The returned items
-
raycast
public void raycast(Ray3D ray, java.util.SortedSet<OctTreeRaycastResultD<T>> items)
Description copied from interface:OctTreeReadableDTypeReturns all objects that are intersected by the given ray. The objects are returned in order of distance from the origin of the ray: The first object returned will be the object nearest to the origin.- Specified by:
raycastin interfaceOctTreeReadableDType<T>- Parameters:
ray- The rayitems- The intersected items
-
-