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 throwsUnsupportedOperationException
for 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 void
addTreeNodeListener(TreeNodeListener listener)
Add a listener on the node events.void
addUserData(int index, D data)
Add a user data associated to this node.boolean
addUserData(int index, Collection<? extends D> data)
Add a user data associated to this node.boolean
addUserData(D data)
Add a user data associated to this node.boolean
addUserData(Collection<? extends D> data)
Add a user data associated to this node.Iterator<N>
children()
Replies the not-null child nodes of this node.void
clear()
Clear the tree.int
compareTo(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.N
getChildAt(int index)
Replies the n-th child in this node.int
getChildCount()
Replies count of children in this node.N[]
getChildren(Class<N> type)
Replies the child nodes of this node.void
getChildren(Object[] array)
Replies the child nodes of this node.int
getDeepNodeCount()
Replies the count of nodes inside the tree for which the root is this node.int
getDeepUserDataCount()
Replies the count of user data inside the tree for which the root is this node.int
getDepth()
Replies the depth level of this node.int[]
getHeights()
Replies the heights of all the leaf nodes.int
getMaxHeight()
Replies the maximal height of the tree.int
getMinHeight()
Replies the minimal height of the tree.int
getNotNullChildCount()
Replies count of not-null children in this node.N
getParentNode()
Replies the parent node ornull
.Class<? extends Enum<?>>
getPartitionEnumeration()
Replies the enumeration type that is defining the children of the nodes.D
getUserData()
Replies the first user data associated to this node.D
getUserDataAt(int index)
Replies the user data associated to this node which is at the specified index.int
getUserDataCount()
Replies the count of user data associated to this node.int
indexOf(N child)
Replies the index of the specified child.boolean
isEmpty()
Replies if this node is a leaf and has no user data.boolean
isLeaf()
Replies if this node is a leaf.boolean
isRoot()
Replies if this node is a root.boolean
isValid()
Replies if this node is a valid.boolean
moveTo(N newParent, int index)
Move this node in the given new node.void
removeAllUserData()
Remove all the user data associated to this node.boolean
removeChild(N child)
Remove the specified node from this node if it is a child.void
removeDeeplyFromParent()
Remove this node from its parent and remove the parent if it is becoming empty, and so one.N
removeFromParent()
Remove this node from its parent.void
removeTreeNodeListener(TreeNodeListener listener)
Remove a listener on the node events.D
removeUserData(int index)
Remove a user data associated to this node.boolean
removeUserData(D data)
Remove a user data associated to this node.boolean
removeUserData(Collection<D> data)
Remove a user data associated to this node.boolean
setChildAt(int index, N child)
Set the n-th child in this node.boolean
setUserData(D data)
Set the user data associated to this node.boolean
setUserData(Collection<D> data)
Set the user data associated to this node.boolean
setUserDataAt(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:TreeNode
Replies the parent node ornull
.
-
setChildAt
public boolean setChildAt(int index, N child) throws IndexOutOfBoundsException
Description copied from interface:TreeNode
Set the n-th child in this node.- Specified by:
setChildAt
in interfaceTreeNode<D,N extends TreeNode<D,N>>
- Parameters:
index
- is the index of the child to replychild
- is the new child node.- Returns:
true
if it was set, otherwisefalse
- Throws:
IndexOutOfBoundsException
- if the given index was invalid
-
indexOf
@Pure public int indexOf(N child)
Description copied from interface:TreeNode
Replies the index of the specified child.
-
getPartitionEnumeration
@Pure public Class<? extends Enum<?>> getPartitionEnumeration()
Description copied from interface:TreeNode
Replies the enumeration type that is defining the children of the nodes.
-
getAllUserData
public D[] getAllUserData(D[] array)
Description copied from interface:TreeNode
Replies the all user data associated to this node.
-
getAllUserData
@Pure public List<D> getAllUserData()
Description copied from interface:TreeNode
Replies the all user data associated to this node.
-
getUserData
@Pure public D getUserData()
Description copied from interface:TreeNode
Replies the first user data associated to this node.
-
getUserDataCount
@Pure public int getUserDataCount()
Description copied from interface:TreeNode
Replies the count of user data associated to this node.
-
getUserDataAt
@Pure public D getUserDataAt(int index) throws IndexOutOfBoundsException
Description copied from interface:TreeNode
Replies the user data associated to this node which is at the specified index.- Specified by:
getUserDataAt
in 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:TreeNode
Add a user data associated to this node.
-
addUserData
public boolean addUserData(int index, Collection<? extends D> data)
Description copied from interface:TreeNode
Add a user data associated to this node.
-
addUserData
public boolean addUserData(D data)
Description copied from interface:TreeNode
Add a user data associated to this node.
-
addUserData
public void addUserData(int index, D data)
Description copied from interface:TreeNode
Add a user data associated to this node.
-
removeUserData
public boolean removeUserData(Collection<D> data)
Description copied from interface:TreeNode
Remove a user data associated to this node.
-
removeUserData
public boolean removeUserData(D data)
Description copied from interface:TreeNode
Remove a user data associated to this node.
-
removeUserData
public D removeUserData(int index)
Description copied from interface:TreeNode
Remove a user data associated to this node.
-
setUserData
public boolean setUserData(Collection<D> data)
Description copied from interface:TreeNode
Set the user data associated to this node.
-
setUserData
public boolean setUserData(D data)
Description copied from interface:TreeNode
Set the user data associated to this node.
-
setUserDataAt
public boolean setUserDataAt(int index, D data) throws IndexOutOfBoundsException
Description copied from interface:TreeNode
Set the user data associated to this node at the specified index.- Specified by:
setUserDataAt
in 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:
true
if the data was successfully set, otherwhisefalse
- Throws:
IndexOutOfBoundsException
- if the given index was invalid
-
addTreeNodeListener
public void addTreeNodeListener(TreeNodeListener listener)
Description copied from interface:TreeNode
Add a listener on the node events.
-
removeTreeNodeListener
public void removeTreeNodeListener(TreeNodeListener listener)
Description copied from interface:TreeNode
Remove a listener on the node events.
-
isEmpty
@Pure public boolean isEmpty()
Description copied from interface:TreeNode
Replies 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:TreeNode
Replies if this node is a root.
-
isValid
@Pure public boolean isValid()
Description copied from interface:TreeNode
Replies if this node is a valid. The validity of a node depends of the node implementation.
-
clear
public void clear()
Description copied from interface:TreeNode
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)
.
-
removeAllUserData
public void removeAllUserData()
Description copied from interface:TreeNode
Remove all the user data associated to this node.
-
removeChild
public boolean removeChild(N child)
Description copied from interface:TreeNode
Remove the specified node from this node if it is a child.
-
removeDeeplyFromParent
public void removeDeeplyFromParent()
Description copied from interface:TreeNode
Remove 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:TreeNode
Replies the count of nodes inside the tree for which the root is this node.
-
getDeepUserDataCount
@Pure public int getDeepUserDataCount()
Description copied from interface:TreeNode
Replies 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:TreeNode
Replies the not-null child nodes of this node.The given iterator never replies a null value for a child node.
- Specified by:
children
in 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: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 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: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 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:TreeNode
Replies the depth level of this node. Depth level0
is the root node,1
are the children of the root node, etc.
-
getMinHeight
@Pure public int getMinHeight()
Description copied from interface:TreeNode
Replies the minimal height of the tree.
-
getMaxHeight
@Pure public int getMaxHeight()
Description copied from interface:TreeNode
Replies the maximal height of the tree.
-
getHeights
@Pure public int[] getHeights()
Description copied from interface:TreeNode
Replies 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:TreeNode
Move 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:IterableNode
Replies the n-th child in this node.- Specified by:
getChildAt
in 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: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>
- Returns:
- the count of children.
- See Also:
IterableNode.getNotNullChildCount()
-
getNotNullChildCount
@Pure public int getNotNullChildCount()
Description copied from interface:IterableNode
Replies 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:
getNotNullChildCount
in interfaceIterableNode<D>
- Returns:
- the count of not-null children.
- See Also:
IterableNode.getChildCount()
-
isLeaf
@Pure public boolean isLeaf()
Description copied from interface:IterableNode
Replies if this node is a leaf.- Specified by:
isLeaf
in interfaceIterableNode<D>
- Returns:
true
is this node is a leaf, otherwisefalse
-
removeFromParent
public N removeFromParent()
Description copied from interface:IterableNode
Remove this node from its parent.- Specified by:
removeFromParent
in interfaceIterableNode<D>
- Returns:
- the parent node from which the node was removed.
-
compareTo
@Pure public int compareTo(N obj)
- Specified by:
compareTo
in interfaceComparable<D>
-
-