Interface IterableTreeNode<O>
-
- All Superinterfaces:
Iterable<IterableTreeNode<?>>,TreeNode
- All Known Implementing Classes:
DefaultIterableTreeNode
public interface IterableTreeNode<O> extends TreeNode, Iterable<IterableTreeNode<?>>
ATreeNodeimplementation that is mutable, but does not implementsMutableTreeNode, because this API has some lacks:- Implementation use
Vector - Methods around userObject are not typed
Iterableto get nice access to children nodes using modern API. In that way we can perform nice and efficient traversal algorithms using exclusivelyStreamAPI.Created by tchemit on 07/01/2018.
- Author:
- Tony Chemit - dev@tchemit.fr
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classIterableTreeNode.BreadthFirstIteratorstatic classIterableTreeNode.PostorderIteratorstatic classIterableTreeNode.PreorderIterator
-
Field Summary
Fields Modifier and Type Field Description static Iterator<IterableTreeNode<?>>EMPTY_ITERATORstatic intSTREAM_CHARACTERISTICS
-
Method Summary
-
Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
Methods inherited from interface javax.swing.tree.TreeNode
children, getAllowsChildren, getChildAt, getChildCount, getIndex, isLeaf
-
-
-
-
Field Detail
-
EMPTY_ITERATOR
static final Iterator<IterableTreeNode<?>> EMPTY_ITERATOR
-
STREAM_CHARACTERISTICS
static final int STREAM_CHARACTERISTICS
- See Also:
- Constant Field Values
-
-
Method Detail
-
stream
static Stream<IterableTreeNode<?>> stream(Iterator<IterableTreeNode<?>> iterator)
-
stream
default Stream<IterableTreeNode<?>> stream()
-
isRoot
boolean isRoot()
-
getRoot
IterableTreeNode<?> getRoot()
-
getParent
IterableTreeNode<?> getParent()
-
setParent
void setParent(IterableTreeNode<?> parent)
-
setAllowsChildren
void setAllowsChildren(boolean allowsChildren)
-
isEmpty
boolean isEmpty()
-
getUserObject
O getUserObject()
-
setUserObject
void setUserObject(O userObject)
-
addChild
void addChild(IterableTreeNode<?> newChild)
-
insertChild
void insertChild(IterableTreeNode<?> newChild, int position)
-
removeChild
void removeChild(int index)
Remove child at givenindex.Will throw exception if no child at index.
- Parameters:
index- position of child to remove
-
removeChild
void removeChild(IterableTreeNode<?> child)
Remove given givenchild.Will throw exception if given child is not a child of this node.
- Parameters:
child- child to remove
-
removeChildren
void removeChildren()
Removes all of this node's children, setting their parents to null. If this node has no children, this method does nothing.
-
removeChildren
void removeChildren(List<IterableTreeNode<?>> children)
Remove given children. Acts as methodremoveChild(IterableTreeNode)for each element.- Parameters:
children- children to remove
-
preorderIterator
default Iterator<IterableTreeNode<?>> preorderIterator()
-
postorderIterator
default Iterator<IterableTreeNode<?>> postorderIterator()
-
breadthFirstIterator
default Iterator<IterableTreeNode<?>> breadthFirstIterator()
-
-