Class OctTreeI<T>

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      protected class  OctTreeI.Octant  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      com.io7m.jregions.core.unparameterized.volumes.VolumeI bounds()  
      void clear()
      Remove all objects from the tree.
      void containedBy​(com.io7m.jregions.core.unparameterized.volumes.VolumeI volume, java.util.Set<T> items)
      Returns all objects in the tree that are completely contained within volume, saving the results to items.
      boolean contains​(T item)
      Determine whether or not the object has already been inserted into the tree.
      static <T> OctTreeIType<T> create​(OctTreeConfigurationI config)
      Create a new empty tree with the given bounds.
      boolean equals​(java.lang.Object o)  
      int hashCode()  
      boolean insert​(T item, com.io7m.jregions.core.unparameterized.volumes.VolumeI item_bounds)
      Insert the object item into the octtree.
      <C> void iterateOctants​(C context, OctTreeOctantIterationIType<T,​C> f)
      Iterate over all octants within the tree.
      <U> OctTreeIType<U> map​(java.util.function.BiFunction<T,​com.io7m.jregions.core.unparameterized.volumes.VolumeI,​U> f)
      Apply f to each element of the tree.
      void overlappedBy​(com.io7m.jregions.core.unparameterized.volumes.VolumeI volume, java.util.Set<T> items)
      Returns all objects in the tree that are overlapped volume, saving the results to items.
      void raycast​(Ray3D ray, java.util.SortedSet<OctTreeRaycastResultI<T>> items)
      Returns all objects that are intersected by the given ray.
      boolean remove​(T item)
      Remove the object item from the octtree.
      long size()  
      void trim()
      Trim all empty quadrants from the tree.
      com.io7m.jregions.core.unparameterized.volumes.VolumeI volumeFor​(T item)  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • create

        public static <T> OctTreeIType<T> create​(OctTreeConfigurationI 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: OctTreeIType
        Trim all empty quadrants from the tree.
        Specified by:
        trim in interface OctTreeIType<T>
      • size

        public long size()
        Specified by:
        size in interface OctTreeReadableType
        Returns:
        The number of elements in the tree
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • bounds

        public com.io7m.jregions.core.unparameterized.volumes.VolumeI bounds()
        Specified by:
        bounds in interface OctTreeReadableIType<T>
        Returns:
        The tree bounds
      • insert

        public boolean insert​(T item,
                              com.io7m.jregions.core.unparameterized.volumes.VolumeI item_bounds)
        Description copied from interface: OctTreeIType

        Insert the object item into the octtree.

        The function returns false if the object could not be inserted for any reason (perhaps due to being too large).

        If the object is already in the tree, it is replaced. This can be used to update the bounds of an object within the tree.

        Specified by:
        insert in interface OctTreeIType<T>
        Parameters:
        item - The object to insert
        item_bounds - The object's bounds
        Returns:
        true if the object was inserted
      • contains

        public boolean contains​(T item)
        Description copied from interface: OctTreeReadableIType
        Determine whether or not the object has already been inserted into the tree.
        Specified by:
        contains in interface OctTreeReadableIType<T>
        Parameters:
        item - The object
        Returns:
        true iff the object is in the tree
      • remove

        public boolean remove​(T item)
        Description copied from interface: OctTreeIType

        Remove the object item from the octtree.

        The function returns false if the object could not be removed for any reason (perhaps due to not being in the tree in the first place).

        Specified by:
        remove in interface OctTreeIType<T>
        Parameters:
        item - The object to remove
        Returns:
        true if the object was removed
      • clear

        public void clear()
        Description copied from interface: OctTreeIType
        Remove all objects from the tree.
        Specified by:
        clear in interface OctTreeIType<T>
      • map

        public <U> OctTreeIType<U> map​(java.util.function.BiFunction<T,​com.io7m.jregions.core.unparameterized.volumes.VolumeI,​U> f)
        Description copied from interface: OctTreeIType
        Apply f to each element of the tree.
        Specified by:
        map in interface OctTreeIType<T>
        Specified by:
        map in interface OctTreeReadableIType<T>
        Type Parameters:
        U - The type of result elements
        Parameters:
        f - A mapping function
        Returns:
        A new tree
      • volumeFor

        public com.io7m.jregions.core.unparameterized.volumes.VolumeI volumeFor​(T item)
        Specified by:
        volumeFor in interface OctTreeReadableIType<T>
        Parameters:
        item - The item
        Returns:
        The bounding volume that was specified for item
      • containedBy

        public void containedBy​(com.io7m.jregions.core.unparameterized.volumes.VolumeI volume,
                                java.util.Set<T> items)
        Description copied from interface: OctTreeReadableIType
        Returns all objects in the tree that are completely contained within volume, saving the results to items.
        Specified by:
        containedBy in interface OctTreeReadableIType<T>
        Parameters:
        volume - The volume to examine
        items - The returned items
      • overlappedBy

        public void overlappedBy​(com.io7m.jregions.core.unparameterized.volumes.VolumeI volume,
                                 java.util.Set<T> items)
        Description copied from interface: OctTreeReadableIType
        Returns all objects in the tree that are overlapped volume, saving the results to items.
        Specified by:
        overlappedBy in interface OctTreeReadableIType<T>
        Parameters:
        volume - The volume to examine
        items - The returned items
      • raycast

        public void raycast​(Ray3D ray,
                            java.util.SortedSet<OctTreeRaycastResultI<T>> items)
        Description copied from interface: OctTreeReadableIType
        Returns 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:
        raycast in interface OctTreeReadableIType<T>
        Parameters:
        ray - The ray
        items - The intersected items