public class DefaultIterableTreeNode<O> extends Object implements IterableTreeNode<O>
IterableTreeNode.
Created by tchemit on 05/01/2018.
IterableTreeNode.BreadthFirstIterator, IterableTreeNode.PostorderIterator, IterableTreeNode.PreorderIteratorEMPTY_ITERATOR, STREAM_CHARACTERISTICS| Constructor and Description |
|---|
DefaultIterableTreeNode(O userObject,
boolean allowsChildren) |
| Modifier and Type | Method and Description |
|---|---|
void |
addChild(IterableTreeNode<?> newChild) |
Enumeration |
children() |
boolean |
getAllowsChildren() |
IterableTreeNode<?> |
getChildAt(int childIndex) |
int |
getChildCount() |
int |
getIndex(TreeNode node) |
IterableTreeNode<?> |
getParent() |
IterableTreeNode<?> |
getRoot() |
O |
getUserObject() |
void |
insertChild(IterableTreeNode<?> newChild,
int position) |
boolean |
isEmpty() |
boolean |
isLeaf() |
boolean |
isNodeAncestor(IterableTreeNode anotherNode)
Returns true if
anotherNode is an ancestor of this node
-- if it is this node, this node's parent, or an ancestor of this
node's parent. |
boolean |
isRoot() |
Iterator<IterableTreeNode<?>> |
iterator() |
void |
removeChild(int index)
Remove child at given
index. |
void |
removeChild(IterableTreeNode<?> child)
Remove given given
child. |
void |
removeChildren()
Removes all of this node's children, setting their parents to null.
|
void |
removeChildren(List<IterableTreeNode<?>> children)
Remove given children.
|
void |
setAllowsChildren(boolean allowsChildren) |
void |
setParent(IterableTreeNode<?> parent) |
void |
setUserObject(O userObject) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitbreadthFirstIterator, postorderIterator, preorderIterator, stream, streamforEach, spliteratorpublic DefaultIterableTreeNode(O userObject, boolean allowsChildren)
public IterableTreeNode<?> getChildAt(int childIndex)
getChildAt in interface TreeNodepublic final int getChildCount()
getChildCount in interface TreeNodepublic final boolean isRoot()
isRoot in interface IterableTreeNode<O>public IterableTreeNode<?> getRoot()
getRoot in interface IterableTreeNode<O>public IterableTreeNode<?> getParent()
getParent in interface TreeNodegetParent in interface IterableTreeNode<O>public final void setParent(IterableTreeNode<?> parent)
setParent in interface IterableTreeNode<O>public final boolean getAllowsChildren()
getAllowsChildren in interface TreeNodepublic final void setAllowsChildren(boolean allowsChildren)
setAllowsChildren in interface IterableTreeNode<O>public final Enumeration children()
public final Iterator<IterableTreeNode<?>> iterator()
iterator in interface Iterable<IterableTreeNode<?>>public final boolean isEmpty()
isEmpty in interface IterableTreeNode<O>public final O getUserObject()
getUserObject in interface IterableTreeNode<O>public final void setUserObject(O userObject)
setUserObject in interface IterableTreeNode<O>public final void addChild(IterableTreeNode<?> newChild)
addChild in interface IterableTreeNode<O>public final void insertChild(IterableTreeNode<?> newChild, int position)
insertChild in interface IterableTreeNode<O>public final void removeChild(IterableTreeNode<?> child)
IterableTreeNodechild.
Will throw exception if given child is not a child of this node.
removeChild in interface IterableTreeNode<O>child - child to removepublic final void removeChild(int index)
IterableTreeNodeindex.
Will throw exception if no child at index.
removeChild in interface IterableTreeNode<O>index - position of child to removepublic void removeChildren()
IterableTreeNoderemoveChildren in interface IterableTreeNode<O>public void removeChildren(List<IterableTreeNode<?>> children)
IterableTreeNodeIterableTreeNode.removeChild(IterableTreeNode) for each element.removeChildren in interface IterableTreeNode<O>children - children to removepublic final boolean isNodeAncestor(IterableTreeNode anotherNode)
anotherNode is an ancestor of this node
-- if it is this node, this node's parent, or an ancestor of this
node's parent. (Note that a node is considered an ancestor of itself.)
If anotherNode is null, this method returns false. This
operation is at worst O(h) where h is the distance from the root to
this node.anotherNode - node to test as an ancestor of this nodeanotherNodeCopyright © 2008–2020 Ultreia.io. All rights reserved.