public class Node<T>
extends java.lang.Object
Constructor and Description |
---|
Node()
Default ctor.
|
Node(T data)
Convenience ctor to create a Node
|
Modifier and Type | Method and Description |
---|---|
void |
addChild(Node<T> child)
Adds a child to the list of children for this Node
|
java.util.List<Node<T>> |
getChildren()
Return the children of Node
|
T |
getData() |
int |
getNumberOfChildren()
Returns the number of immediate children of this Node
|
Node<T> |
getParent() |
void |
insertChildAt(int index,
Node<T> child)
Inserts a Node
|
void |
removeChildAt(int index)
Remove the Node
|
void |
setChildren(java.util.List<Node<T>> children)
Sets the children of a Node
|
void |
setData(T data) |
void |
setParent(Node<T> parent) |
java.lang.String |
toString() |
public Node()
public Node(T data)
data
- an instance of T.public java.util.List<Node<T>> getChildren()
public void setChildren(java.util.List<Node<T>> children)
children
- the Listpublic int getNumberOfChildren()
public void addChild(Node<T> child)
child
- a Nodepublic void insertChildAt(int index, Node<T> child) throws java.lang.IndexOutOfBoundsException
index
- the position to insert at.child
- the Nodejava.lang.IndexOutOfBoundsException
- if thrown.public void removeChildAt(int index) throws java.lang.IndexOutOfBoundsException
index
- the index of the element to delete.java.lang.IndexOutOfBoundsException
- if thrown.public T getData()
public void setData(T data)
public java.lang.String toString()
toString
in class java.lang.Object