Class UnsupportedOperationTreeNode<D,N extends TreeNode<D,N>>
- java.lang.Object
-
- org.arakhne.afc.math.tree.node.UnsupportedOperationTreeNode<D,N>
-
- Type Parameters:
D- is the type of the data inside the treeN- is the type of the tree nodes.
- All Implemented Interfaces:
Comparable<N>,IterableNode<N>,TreeNode<D,N>
public class UnsupportedOperationTreeNode<D,N extends TreeNode<D,N>> extends Object implements TreeNode<D,N>
Generic implementation of a tree node that throwsUnsupportedOperationExceptionfor all its operation. The sub classes must override the operations to provide a different behaviors.- Since:
- 13.0
- Version:
- 17.0 2020-01-04 14:41:41
- Author:
- Stéphane GALLAND
- Maven Group Id:
- org.arakhne.afc.core
- Maven Artifact Id:
- mathtree
-
-
Constructor Summary
Constructors Constructor Description UnsupportedOperationTreeNode()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddTreeNodeListener(TreeNodeListener listener)Add a listener on the node events.voidaddUserData(int index, D data)Add a user data associated to this node.booleanaddUserData(int index, Collection<? extends D> data)Add a user data associated to this node.booleanaddUserData(D data)Add a user data associated to this node.booleanaddUserData(Collection<? extends D> data)Add a user data associated to this node.Iterator<N>children()Replies the not-null child nodes of this node.voidclear()Clear the tree.intcompareTo(N obj)List<D>getAllUserData()Replies the all user data associated to this node.D[]getAllUserData(D[] array)Replies the all user data associated to this node.NgetChildAt(int index)Replies the n-th child in this node.intgetChildCount()Replies count of children in this node.N[]getChildren(Class<N> type)Replies the child nodes of this node.voidgetChildren(Object[] array)Replies the child nodes of this node.intgetDeepNodeCount()Replies the count of nodes inside the tree for which the root is this node.intgetDeepUserDataCount()Replies the count of user data inside the tree for which the root is this node.intgetDepth()Replies the depth level of this node.int[]getHeights()Replies the heights of all the leaf nodes.intgetMaxHeight()Replies the maximal height of the tree.intgetMinHeight()Replies the minimal height of the tree.intgetNotNullChildCount()Replies count of not-null children in this node.NgetParentNode()Replies the parent node ornull.Class<? extends Enum<?>>getPartitionEnumeration()Replies the enumeration type that is defining the children of the nodes.DgetUserData()Replies the first user data associated to this node.DgetUserDataAt(int index)Replies the user data associated to this node which is at the specified index.intgetUserDataCount()Replies the count of user data associated to this node.intindexOf(N child)Replies the index of the specified child.booleanisEmpty()Replies if this node is a leaf and has no user data.booleanisLeaf()Replies if this node is a leaf.booleanisRoot()Replies if this node is a root.booleanisValid()Replies if this node is a valid.booleanmoveTo(N newParent, int index)Move this node in the given new node.voidremoveAllUserData()Remove all the user data associated to this node.booleanremoveChild(N child)Remove the specified node from this node if it is a child.voidremoveDeeplyFromParent()Remove this node from its parent and remove the parent if it is becoming empty, and so one.NremoveFromParent()Remove this node from its parent.voidremoveTreeNodeListener(TreeNodeListener listener)Remove a listener on the node events.DremoveUserData(int index)Remove a user data associated to this node.booleanremoveUserData(D data)Remove a user data associated to this node.booleanremoveUserData(Collection<D> data)Remove a user data associated to this node.booleansetChildAt(int index, N child)Set the n-th child in this node.booleansetUserData(D data)Set the user data associated to this node.booleansetUserData(Collection<D> data)Set the user data associated to this node.booleansetUserDataAt(int index, D data)Set the user data associated to this node at the specified index.
-
-
-
Method Detail
-
getParentNode
@Pure public N getParentNode()
Description copied from interface:TreeNodeReplies the parent node ornull.
-
setChildAt
public boolean setChildAt(int index, N child) throws IndexOutOfBoundsExceptionDescription copied from interface:TreeNodeSet the n-th child in this node.- Specified by:
setChildAtin interfaceTreeNode<D,N extends TreeNode<D,N>>- Parameters:
index- is the index of the child to replychild- is the new child node.- Returns:
trueif it was set, otherwisefalse- Throws:
IndexOutOfBoundsException- if the given index was invalid
-
indexOf
@Pure public int indexOf(N child)
Description copied from interface:TreeNodeReplies the index of the specified child.
-
getPartitionEnumeration
@Pure public Class<? extends Enum<?>> getPartitionEnumeration()
Description copied from interface:TreeNodeReplies the enumeration type that is defining the children of the nodes.
-
getAllUserData
public D[] getAllUserData(D[] array)
Description copied from interface:TreeNodeReplies the all user data associated to this node.
-
getAllUserData
@Pure public List<D> getAllUserData()
Description copied from interface:TreeNodeReplies the all user data associated to this node.
-
getUserData
@Pure public D getUserData()
Description copied from interface:TreeNodeReplies the first user data associated to this node.
-
getUserDataCount
@Pure public int getUserDataCount()
Description copied from interface:TreeNodeReplies the count of user data associated to this node.
-
getUserDataAt
@Pure public D getUserDataAt(int index) throws IndexOutOfBoundsException
Description copied from interface:TreeNodeReplies the user data associated to this node which is at the specified index.- Specified by:
getUserDataAtin interfaceTreeNode<D,N extends TreeNode<D,N>>- Parameters:
index- is the position of the data to reply- Returns:
- the user data
- Throws:
IndexOutOfBoundsException- when the given index in not valid
-
addUserData
public boolean addUserData(Collection<? extends D> data)
Description copied from interface:TreeNodeAdd a user data associated to this node.
-
addUserData
public boolean addUserData(int index, Collection<? extends D> data)Description copied from interface:TreeNodeAdd a user data associated to this node.
-
addUserData
public boolean addUserData(D data)
Description copied from interface:TreeNodeAdd a user data associated to this node.
-
addUserData
public void addUserData(int index, D data)Description copied from interface:TreeNodeAdd a user data associated to this node.
-
removeUserData
public boolean removeUserData(Collection<D> data)
Description copied from interface:TreeNodeRemove a user data associated to this node.
-
removeUserData
public boolean removeUserData(D data)
Description copied from interface:TreeNodeRemove a user data associated to this node.
-
removeUserData
public D removeUserData(int index)
Description copied from interface:TreeNodeRemove a user data associated to this node.
-
setUserData
public boolean setUserData(Collection<D> data)
Description copied from interface:TreeNodeSet the user data associated to this node.
-
setUserData
public boolean setUserData(D data)
Description copied from interface:TreeNodeSet the user data associated to this node.
-
setUserDataAt
public boolean setUserDataAt(int index, D data) throws IndexOutOfBoundsExceptionDescription copied from interface:TreeNodeSet the user data associated to this node at the specified index.- Specified by:
setUserDataAtin interfaceTreeNode<D,N extends TreeNode<D,N>>- Parameters:
index- the index at which the data must be set.data- the data to put inside.- Returns:
trueif the data was successfully set, otherwhisefalse- Throws:
IndexOutOfBoundsException- if the given index was invalid
-
addTreeNodeListener
public void addTreeNodeListener(TreeNodeListener listener)
Description copied from interface:TreeNodeAdd a listener on the node events.
-
removeTreeNodeListener
public void removeTreeNodeListener(TreeNodeListener listener)
Description copied from interface:TreeNodeRemove a listener on the node events.
-
isEmpty
@Pure public boolean isEmpty()
Description copied from interface:TreeNodeReplies if this node is a leaf and has no user data.This function is equivalent to call
IterableNode.isLeaf()&&TreeNode.getUserDataCount()==0
-
isRoot
@Pure public boolean isRoot()
Description copied from interface:TreeNodeReplies if this node is a root.
-
isValid
@Pure public boolean isValid()
Description copied from interface:TreeNodeReplies if this node is a valid. The validity of a node depends of the node implementation.
-
clear
public void clear()
Description copied from interface:TreeNodeClear 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).
-
removeAllUserData
public void removeAllUserData()
Description copied from interface:TreeNodeRemove all the user data associated to this node.
-
removeChild
public boolean removeChild(N child)
Description copied from interface:TreeNodeRemove the specified node from this node if it is a child.
-
removeDeeplyFromParent
public void removeDeeplyFromParent()
Description copied from interface:TreeNodeRemove this node from its parent and remove the parent if it is becoming empty, and so one.
-
getDeepNodeCount
@Pure public int getDeepNodeCount()
Description copied from interface:TreeNodeReplies the count of nodes inside the tree for which the root is this node.
-
getDeepUserDataCount
@Pure public int getDeepUserDataCount()
Description copied from interface:TreeNodeReplies the count of user data inside the tree for which the root is this node.
-
children
@Pure public Iterator<N> children()
Description copied from interface:TreeNodeReplies the not-null child nodes of this node.The given iterator never replies a null value for a child node.
- Specified by:
childrenin interfaceTreeNode<D,N extends TreeNode<D,N>>- Returns:
- the children.
- See Also:
TreeNode.getChildren(Object[]),TreeNode.getChildren(Class)
-
getChildren
@Pure public N[] getChildren(Class<N> type)
Description copied from interface:TreeNodeReplies the child nodes of this node.This function may put
nullin the array cells if the current tree node has not a child at the corresponding index.- Specified by:
getChildrenin interfaceTreeNode<D,N extends TreeNode<D,N>>- Parameters:
type- is the type of the children to reply.- Returns:
- the children.
- See Also:
TreeNode.getChildren(Object[]),TreeNode.children()
-
getChildren
public void getChildren(Object[] array)
Description copied from interface:TreeNodeReplies the child nodes of this node.This function may put
nullin the array cells if the current tree node has not a child at the corresponding index.- Specified by:
getChildrenin interfaceTreeNode<D,N extends TreeNode<D,N>>- Parameters:
array- is the array to fill.- See Also:
TreeNode.getChildren(Class),TreeNode.children()
-
getDepth
@Pure public int getDepth()
Description copied from interface:TreeNodeReplies the depth level of this node. Depth level0is the root node,1are the children of the root node, etc.
-
getMinHeight
@Pure public int getMinHeight()
Description copied from interface:TreeNodeReplies the minimal height of the tree.
-
getMaxHeight
@Pure public int getMaxHeight()
Description copied from interface:TreeNodeReplies the maximal height of the tree.
-
getHeights
@Pure public int[] getHeights()
Description copied from interface:TreeNodeReplies the heights of all the leaf nodes. The order of the heights is given by a depth-first iteration.
-
moveTo
public boolean moveTo(N newParent, int index)
Description copied from interface:TreeNodeMove this node in the given new node.If any child node is already present at the given position in the new parent node, the tree node may replace the existing node or insert the moving node according to its implementation.
This function is preferred to a sequence of calls to
IterableNode.removeFromParent()andTreeNode.setChildAt(int, TreeNode)because it fires a limited set of events dedicated to the move the node.
-
getChildAt
@Pure public N getChildAt(int index) throws IndexOutOfBoundsException
Description copied from interface:IterableNodeReplies the n-th child in this node.- Specified by:
getChildAtin interfaceIterableNode<D>- Parameters:
index- is the index of the child to reply- Returns:
- the child node.
- Throws:
IndexOutOfBoundsException- if the given index was invalid
-
getChildCount
@Pure public int getChildCount()
Description copied from interface:IterableNodeReplies count of children in this node.The number of children is greater or equal to the value replied by
IterableNode.getNotNullChildCount().- Specified by:
getChildCountin interfaceIterableNode<D>- Returns:
- the count of children.
- See Also:
IterableNode.getNotNullChildCount()
-
getNotNullChildCount
@Pure public int getNotNullChildCount()
Description copied from interface:IterableNodeReplies count of not-null children in this node.The number of not-null children is lower or equal to the value replied by
IterableNode.getChildCount().- Specified by:
getNotNullChildCountin interfaceIterableNode<D>- Returns:
- the count of not-null children.
- See Also:
IterableNode.getChildCount()
-
isLeaf
@Pure public boolean isLeaf()
Description copied from interface:IterableNodeReplies if this node is a leaf.- Specified by:
isLeafin interfaceIterableNode<D>- Returns:
trueis this node is a leaf, otherwisefalse
-
removeFromParent
public N removeFromParent()
Description copied from interface:IterableNodeRemove this node from its parent.- Specified by:
removeFromParentin interfaceIterableNode<D>- Returns:
- the parent node from which the node was removed.
-
compareTo
@Pure public int compareTo(N obj)
- Specified by:
compareToin interfaceComparable<D>
-
-