Package org.arakhne.afc.math.tree.node
Class IcosepOctTreeNode<D,N extends IcosepOctTreeNode<D,N>>
- java.lang.Object
-
- org.arakhne.afc.math.tree.node.AbstractParentlessTreeNode<D,N>
-
- org.arakhne.afc.math.tree.node.AbstractTreeNode<D,N>
-
- org.arakhne.afc.math.tree.node.OctTreeNode<D,N>
-
- org.arakhne.afc.math.tree.node.IcosepOctTreeNode<D,N>
-
- Type Parameters:
D
- is the type of the data inside the treeN
- is the type of the tree nodes.
- All Implemented Interfaces:
Serializable
,Comparable<N>
,IcosepTreeNodeContainer<N>
,IterableNode<N>
,TreeNode<D,N>
,JsonableObject
- Direct Known Subclasses:
IcosepOctTreeNode.DefaultIcosepOctTreeNode
public abstract class IcosepOctTreeNode<D,N extends IcosepOctTreeNode<D,N>> extends OctTreeNode<D,N> implements IcosepTreeNodeContainer<N>
This is the generic implementation of a tree for which each node has height children and that implements the Icosep heuristic.The icosep heuristic implies that all objects that intersect the split lines will be stored inside an addition child that contains only the corresponding objects.
- Since:
- 13.0
- Version:
- 17.0 2020-01-04 14:41:41
- Author:
- Stéphane GALLAND
- See Also:
- Serialized Form
- Maven Group Id:
- org.arakhne.afc.core
- Maven Artifact Id:
- mathtree
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
IcosepOctTreeNode.DefaultIcosepOctTreeNode<D>
This is the generic implementation of a quad tree with icosep heuristic.static class
IcosepOctTreeNode.IcosepOctTreeZone
This is the generic implementation of a tree for which each node has eight children.-
Nested classes/interfaces inherited from class org.arakhne.afc.math.tree.node.OctTreeNode
OctTreeNode.DefaultOctTreeNode<D>, OctTreeNode.OctTreeZone
-
-
Field Summary
-
Fields inherited from class org.arakhne.afc.math.tree.node.AbstractParentlessTreeNode
DEFAULT_COPY_USER_DATA, DEFAULT_LINK_LIST_USE, nodeListeners, notNullChildCount
-
-
Constructor Summary
Constructors Constructor Description IcosepOctTreeNode()
Empty node.IcosepOctTreeNode(boolean useLinkedList)
Construct a node.IcosepOctTreeNode(boolean useLinkedList, boolean copyDataCollection, List<D> data)
Construct a node.IcosepOctTreeNode(boolean useLinkedList, D data)
Construct a node.IcosepOctTreeNode(D data)
Construct a node.IcosepOctTreeNode(Collection<D> data)
Construct a node.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Clear the tree.N
getChildAt(int index)
Replies the n-th child in this node.N
getChildAt(IcosepOctTreeNode.IcosepOctTreeZone zone)
Replies the node that is corresponding to the given zone.int
getChildCount()
Replies count of children in this node.void
getChildren(Object[] array)
Replies the child nodes of this node.protected void
getHeights(int currentHeight, List<Integer> heights)
Replies the heights of all the leaf nodes.N
getIcosepChild()
Get the icosep node of this node.int
getMaxHeight()
Replies the maximal height of the tree.int
getMinHeight()
Replies the minimal height of the tree.Class<? extends Enum<?>>
getPartitionEnumeration()
Replies the enumeration type that is defining the children of the nodes.int
indexOf(N child)
Replies the index of the specified child.boolean
isLeaf()
Replies if this node is a leaf.boolean
removeChild(N child)
Remove the specified node from this node if it is a child.boolean
setChildAt(int index, N newChild)
Set the n-th child in this node.protected void
setChildAtWithoutEventFiring(int index, N newChild)
Invoked by the inner classes to set the child at the given index without firing the events.boolean
setIcosepChild(N newChild)
Set the icosep child of this node.-
Methods inherited from class org.arakhne.afc.math.tree.node.OctTreeNode
getChildAt, getNotNullChildCount, moveTo, moveTo, setChildAt, zoneOf
-
Methods inherited from class org.arakhne.afc.math.tree.node.AbstractTreeNode
children, firePropertyChildAdded, firePropertyChildAdded, firePropertyChildRemoved, firePropertyChildRemoved, firePropertyParentChanged, firePropertyParentChanged, firePropertyParentChanged, getChildren, getDepth, getParentNode, isRoot, moveTo, removeDeeplyFromParent, removeFromParent, setParentNodeReference
-
Methods inherited from class org.arakhne.afc.math.tree.node.AbstractParentlessTreeNode
addTreeNodeListener, addUserData, addUserData, addUserData, addUserData, compareTo, firePropertyDataChanged, firePropertyDataChanged, firePropertyDataChanged, getAllUserData, getAllUserData, getDeepNodeCount, getDeepUserDataCount, getHeights, getInternalDataStructureForUserData, getUserData, getUserDataAt, getUserDataCount, isEmpty, isValid, removeAllUserData, removeTreeNodeListener, removeUserData, removeUserData, removeUserData, setUserData, setUserData, setUserDataAt, toJson, toN, toString
-
-
-
-
Constructor Detail
-
IcosepOctTreeNode
public IcosepOctTreeNode()
Empty node.
-
IcosepOctTreeNode
public IcosepOctTreeNode(Collection<D> data)
Construct a node.- Parameters:
data
- are the initial user data
-
IcosepOctTreeNode
public IcosepOctTreeNode(D data)
Construct a node.- Parameters:
data
- are the initial user data
-
IcosepOctTreeNode
public IcosepOctTreeNode(boolean useLinkedList)
Construct a node.- Parameters:
useLinkedList
- indicates if a linked list must be used to store the data. Iffalse
, an ArrayList will be used.
-
IcosepOctTreeNode
public IcosepOctTreeNode(boolean useLinkedList, boolean copyDataCollection, List<D> data)
Construct a node.- Parameters:
useLinkedList
- indicates if a linked list must be used to store the data. Iffalse
, an ArrayList will be used.copyDataCollection
- indicates if the given data collection is copied iftrue
or the inner data collection will be the given collection itself iffalse
.data
- are the initial user data
-
IcosepOctTreeNode
public IcosepOctTreeNode(boolean useLinkedList, D data)
Construct a node.- Parameters:
useLinkedList
- indicates if a linked list must be used to store the data. Iffalse
, an ArrayList will be used.data
- are the initial user data
-
-
Method Detail
-
getPartitionEnumeration
@Pure public Class<? extends Enum<?>> getPartitionEnumeration()
Description copied from interface:TreeNode
Replies the enumeration type that is defining the children of the nodes.- Specified by:
getPartitionEnumeration
in interfaceTreeNode<D,N extends IcosepOctTreeNode<D,N>>
- Overrides:
getPartitionEnumeration
in classOctTreeNode<D,N extends IcosepOctTreeNode<D,N>>
- Returns:
- the enumeration type of the child partition,
or
null
if no such enumeration type is defined.
-
clear
public void clear()
Clear the tree.Caution: this method also destroyes the links between the child nodes inside the tree. If you want to unlink the first-level child node with this node but leave the rest of the tree unchanged, please call
setChildAt(i,null)
.- Specified by:
clear
in interfaceTreeNode<D,N extends IcosepOctTreeNode<D,N>>
- Overrides:
clear
in classOctTreeNode<D,N extends IcosepOctTreeNode<D,N>>
-
getChildCount
@Pure public int getChildCount()
Description copied from interface:IterableNode
Replies count of children in this node.The number of children is greater or equal to the value replied by
IterableNode.getNotNullChildCount()
.- Specified by:
getChildCount
in interfaceIterableNode<D>
- Overrides:
getChildCount
in classOctTreeNode<D,N extends IcosepOctTreeNode<D,N>>
- Returns:
- the count of children.
- See Also:
IterableNode.getNotNullChildCount()
-
getChildAt
@Pure public N getChildAt(int index) throws IndexOutOfBoundsException
Description copied from interface:IterableNode
Replies the n-th child in this node.- Specified by:
getChildAt
in interfaceIterableNode<D>
- Overrides:
getChildAt
in classOctTreeNode<D,N extends IcosepOctTreeNode<D,N>>
- Parameters:
index
- is the index of the child to reply- Returns:
- the child node.
- Throws:
IndexOutOfBoundsException
- if the given index was invalid
-
getChildAt
@Pure public N getChildAt(IcosepOctTreeNode.IcosepOctTreeZone zone)
Replies the node that is corresponding to the given zone.- Parameters:
zone
- the zone.- Returns:
- the child node for the given zone, or
null
-
setIcosepChild
public boolean setIcosepChild(N newChild)
Description copied from interface:IcosepTreeNodeContainer
Set the icosep child of this node.- Specified by:
setIcosepChild
in interfaceIcosepTreeNodeContainer<D>
- Parameters:
newChild
- is the new child used as the icosep branch- Returns:
true
on success, otherwisefalse
-
getIcosepChild
@Pure public N getIcosepChild()
Description copied from interface:IcosepTreeNodeContainer
Get the icosep node of this node.- Specified by:
getIcosepChild
in interfaceIcosepTreeNodeContainer<D>
- Returns:
- the node that is used as the icosep branch.
-
isLeaf
@Pure public boolean isLeaf()
Description copied from interface:IterableNode
Replies if this node is a leaf.- Specified by:
isLeaf
in interfaceIterableNode<D>
- Overrides:
isLeaf
in classOctTreeNode<D,N extends IcosepOctTreeNode<D,N>>
- Returns:
true
is this node is a leaf, otherwisefalse
-
setChildAt
public boolean setChildAt(int index, N newChild) throws IndexOutOfBoundsException
Description copied from interface:TreeNode
Set the n-th child in this node.- Specified by:
setChildAt
in interfaceTreeNode<D,N extends IcosepOctTreeNode<D,N>>
- Overrides:
setChildAt
in classOctTreeNode<D,N extends IcosepOctTreeNode<D,N>>
- Parameters:
index
- is the index of the child to replynewChild
- is the new child node.- Returns:
true
if it was set, otherwisefalse
- Throws:
IndexOutOfBoundsException
- if the given index was invalid
-
setChildAtWithoutEventFiring
protected void setChildAtWithoutEventFiring(int index, N newChild) throws IndexOutOfBoundsException
Description copied from class:AbstractTreeNode
Invoked by the inner classes to set the child at the given index without firing the events. This function should never invokeAbstractTreeNode.setParentNodeReference(AbstractTreeNode, boolean)
.- Overrides:
setChildAtWithoutEventFiring
in classOctTreeNode<D,N extends IcosepOctTreeNode<D,N>>
- Parameters:
index
- is the position of the new child.newChild
- is the new child- Throws:
IndexOutOfBoundsException
- if the index is invalid.
-
removeChild
public boolean removeChild(N child)
Description copied from interface:TreeNode
Remove the specified node from this node if it is a child.- Specified by:
removeChild
in interfaceTreeNode<D,N extends IcosepOctTreeNode<D,N>>
- Overrides:
removeChild
in classOctTreeNode<D,N extends IcosepOctTreeNode<D,N>>
- Parameters:
child
- is the child to remove.- Returns:
true
if the node was removed, otherwisefalse
-
indexOf
@Pure public int indexOf(N child)
Description copied from interface:TreeNode
Replies the index of the specified child.- Specified by:
indexOf
in interfaceTreeNode<D,N extends IcosepOctTreeNode<D,N>>
- Overrides:
indexOf
in classOctTreeNode<D,N extends IcosepOctTreeNode<D,N>>
- Parameters:
child
- is the node to search for.- Returns:
- the index or
-1
.
-
getChildren
public void getChildren(Object[] array)
Description copied from interface:TreeNode
Replies the child nodes of this node.This function may put
null
in the array cells if the current tree node has not a child at the corresponding index.- Specified by:
getChildren
in interfaceTreeNode<D,N extends IcosepOctTreeNode<D,N>>
- Overrides:
getChildren
in classOctTreeNode<D,N extends IcosepOctTreeNode<D,N>>
- Parameters:
array
- is the array to fill.- See Also:
TreeNode.getChildren(Class)
,TreeNode.children()
-
getMinHeight
@Pure public int getMinHeight()
Description copied from interface:TreeNode
Replies the minimal height of the tree.- Specified by:
getMinHeight
in interfaceTreeNode<D,N extends IcosepOctTreeNode<D,N>>
- Overrides:
getMinHeight
in classOctTreeNode<D,N extends IcosepOctTreeNode<D,N>>
- Returns:
- the height of the uppest leaf in the tree.
-
getMaxHeight
@Pure public int getMaxHeight()
Description copied from interface:TreeNode
Replies the maximal height of the tree.- Specified by:
getMaxHeight
in interfaceTreeNode<D,N extends IcosepOctTreeNode<D,N>>
- Overrides:
getMaxHeight
in classOctTreeNode<D,N extends IcosepOctTreeNode<D,N>>
- Returns:
- the height of the lowest leaf in the tree.
-
getHeights
protected void getHeights(int currentHeight, List<Integer> heights)
Description copied from class:AbstractParentlessTreeNode
Replies the heights of all the leaf nodes. The order of the heights is given by a depth-first iteration.- Overrides:
getHeights
in classOctTreeNode<D,N extends IcosepOctTreeNode<D,N>>
- Parameters:
currentHeight
- is the current height of this node.heights
- is the list of heights to fill
-
-