Package com.io7m.jorchard.core
Interface JOTreeNodeType<A>
- Type Parameters:
A- The type of contained values.
- All Superinterfaces:
JOTreeNodeReadableType<A>
- All Known Implementing Classes:
JOTreeNode
The type of tree nodes.
-
Method Summary
Modifier and TypeMethodDescriptionchildAdd(JOTreeNodeType<A> child) Add a child to this node.childRemove(JOTreeNodeType<A> child) Remove a child from this node.children()default voidchildrenSort(Comparator<A> comparator) Sort the children of this node.voidchildrenSortNodes(Comparator<JOTreeNodeType<A>> comparator) Sort the children of this node.detach()Detach this node from its parent node.parent()setParent(JOTreeNodeType<A> new_parent) Set this node's parent tonew_parent.Methods inherited from interface com.io7m.jorchard.core.JOTreeNodeReadableType
childrenReadable, forEachBreadthFirst, forEachDepthFirst, isDescendantOf, isDetachAllowed, isRoot, mapBreadthFirst, mapDepthFirst, parentReadable, value
-
Method Details
-
detach
JOTreeNodeType<A> detach()Detach this node from its parent node.- Returns:
- this
-
children
List<JOTreeNodeType<A>> children()- Returns:
- A read-only collection containing the children of this node
-
childRemove
Remove a child from this node. Has no effect if the given node is not a child of this node.- Parameters:
child- A child node- Returns:
- this
-
childAdd
Add a child to this node. Has no effect if the given node is already a child of this node.- Parameters:
child- A child node- Returns:
- this
- Throws:
JOTreeExceptionCycle- Iff adding the child would introduce a cycle in the tree
-
setParent
Set this node's parent tonew_parent.- Parameters:
new_parent- The new parent node- Returns:
- this
- Throws:
JOTreeExceptionCycle- Iff setting the parent would introduce a cycle in the tree
-
parent
Optional<JOTreeNodeType<A>> parent()- Returns:
- A reference to the parent node, if any
-
childrenSortNodes
Sort the children of this node. This will affect subsequent calls toJOTreeNodeReadableType.forEachDepthFirst(Object, JOTreeNodeForEachFunctionType)andJOTreeNodeReadableType.forEachBreadthFirst(Object, JOTreeNodeForEachFunctionType), and will affect the order ofchildren().- Parameters:
comparator- A node comparator
-
childrenSort
Sort the children of this node. This will affect subsequent calls toJOTreeNodeReadableType.forEachDepthFirst(Object, JOTreeNodeForEachFunctionType)andJOTreeNodeReadableType.forEachBreadthFirst(Object, JOTreeNodeForEachFunctionType), and will affect the order ofchildren().- Parameters:
comparator- A node comparator
-