public class TreeNode<T>
extends java.lang.Object
Constructor and Description |
---|
TreeNode()
Constructor
|
TreeNode(T d)
Constructor
|
Modifier and Type | Method and Description |
---|---|
void |
addChild(TreeNode<T> element)
Adds a new child to the node
|
boolean |
deleteChild(int pos)
Deletes a child of the node.
|
void |
deleteChildren()
Deletes the children of the node
|
IList<TreeNode<T>> |
getChildren()
Returns a list with its children
|
int |
getCost()
Gets the cost of the last operation performed
|
T |
getData()
Gets the data of the node
|
TreeNode<T> |
getFather()
Gets the father of the node
|
TreeNode<T> |
getFirstChild()
Returns the first child of the node
|
TreeNode<T> |
getLastChild()
Returns the last child of the node
|
TreeNode<T> |
getNextSibling()
Returns the next sibling of the node
|
TreeNode<T> |
getPreviousSibling()
Returns the next sibling of the node
|
boolean |
hasChildren()
Checks if the node has children. if it has children returns true, if not
returns false
|
void |
setData(T value)
Sets the data of the node
|
void |
setFather(TreeNode<T> p)
Sets the father of the node
|
java.lang.String |
toString()
Returns a string with the data of the node
|
public TreeNode(T d)
d
- the data of the nodepublic TreeNode()
public void setFather(TreeNode<T> p)
p
- the reference of the node that we want to set as the fatherpublic TreeNode<T> getFather()
public T getData()
public void setData(T value)
value
- the value of the datapublic IList<TreeNode<T>> getChildren()
public TreeNode<T> getFirstChild()
public TreeNode<T> getLastChild()
public TreeNode<T> getNextSibling()
public TreeNode<T> getPreviousSibling()
public void addChild(TreeNode<T> element)
element
- the data of the new childpublic java.lang.String toString()
toString
in class java.lang.Object
public boolean hasChildren()
public boolean deleteChild(int pos)
pos
- the position of the child in the listpublic void deleteChildren()
public int getCost()