TreeNode -
Adapted from https://code.google.com/p/treelayout/ to be available to GWT clients
public abstract class AbstractTreeForTreeLayout<TreeNode> extends Object implements TreeForTreeLayout<TreeNode>
TreeForTreeLayout interface by
defining just two simple methods and a constructor.
To use this class the underlying tree must provide the children as a list
(see getChildrenList(Object) and give direct access to the parent of
a node (see getParent(Object)).
| Constructor and Description |
|---|
AbstractTreeForTreeLayout(TreeNode root) |
| Modifier and Type | Method and Description |
|---|---|
Iterable<TreeNode> |
getChildren(TreeNode node)
Returns the children of a parent node.
|
abstract List<TreeNode> |
getChildrenList(TreeNode node)
Return the children of a node as a
List. |
Iterable<TreeNode> |
getChildrenReverse(TreeNode node)
Returns the children of a parent node, in reverse order.
|
TreeNode |
getFirstChild(TreeNode parentNode)
Returns the first child of a parent node.
|
TreeNode |
getLastChild(TreeNode parentNode)
Returns the last child of a parent node.
|
abstract TreeNode |
getParent(TreeNode node)
Returns the parent of a node, if it has one.
|
TreeNode |
getRoot()
Returns the the root of the tree.
|
boolean |
isChildOfParent(TreeNode node,
TreeNode parentNode)
Tells if a node is a child of a given parentNode.
|
boolean |
isLeaf(TreeNode node)
Tells if a node is a leaf in the tree.
|
public AbstractTreeForTreeLayout(TreeNode root)
public abstract TreeNode getParent(TreeNode node)
Time Complexity: O(1)
node - public abstract List<TreeNode> getChildrenList(TreeNode node)
List.
Time Complexity: O(1)
Also the access to an item of the list must have time complexity O(1).
A client must not modify the returned list.
node - public TreeNode getRoot()
TreeForTreeLayoutTime Complexity: O(1)
getRoot in interface TreeForTreeLayout<TreeNode>public boolean isLeaf(TreeNode node)
TreeForTreeLayoutTime Complexity: O(1)
isLeaf in interface TreeForTreeLayout<TreeNode>public boolean isChildOfParent(TreeNode node, TreeNode parentNode)
TreeForTreeLayoutTime Complexity: O(1)
isChildOfParent in interface TreeForTreeLayout<TreeNode>public Iterable<TreeNode> getChildren(TreeNode node)
TreeForTreeLayoutTime Complexity: O(1)
getChildren in interface TreeForTreeLayout<TreeNode>node - [!isLeaf(parentNode)]public Iterable<TreeNode> getChildrenReverse(TreeNode node)
TreeForTreeLayoutTime Complexity: O(1)
getChildrenReverse in interface TreeForTreeLayout<TreeNode>node - [!isLeaf(parentNode)]public TreeNode getFirstChild(TreeNode parentNode)
TreeForTreeLayoutTime Complexity: O(1)
getFirstChild in interface TreeForTreeLayout<TreeNode>parentNode - [!isLeaf(parentNode)]public TreeNode getLastChild(TreeNode parentNode)
TreeForTreeLayout
Time Complexity: O(1)
getLastChild in interface TreeForTreeLayout<TreeNode>parentNode - [!isLeaf(parentNode)]Copyright © 2012–2020 JBoss by Red Hat. All rights reserved.