public class TreeNode
extends java.lang.Object
History:
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
END_NODE_STR
the name of end node, the end of a branch
|
static java.lang.String |
ROOT_NODE_STR
the name of root node, the starting node of the entire tree
|
Constructor and Description |
---|
TreeNode()
Create a tree node with default values
|
TreeNode(java.lang.String key)
Create a tree node with specifying key
|
TreeNode(java.lang.String key,
int level)
Create a tree node with specifying key and level
|
TreeNode(java.lang.String key,
int level,
java.util.HashMap<java.lang.String,TreeNode> children)
Create a tree node with specifying key, level, and children
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object obj)
Check if two tree nodes are equals.
|
java.util.HashMap<java.lang.String,TreeNode> |
GetChildren()
Get children of the node
|
int |
GetChildrenNo()
Get the total number of children of the node
|
java.lang.String |
GetDetailString()
Convert the node to a string in detail
|
java.lang.String |
GetKey()
Get key of the node
|
int |
GetLevel()
Get level of the node
|
int |
hashCode()
the hashcode value of the tree node.
|
static void |
main(java.lang.String[] args)
Test driver for this class.
|
void |
SetChildren(java.util.HashMap<java.lang.String,TreeNode> children)
Set the value of children.
|
java.lang.String |
ToString()
Convert the node to a string in the format of [key|level|children number]
|
public static final java.lang.String ROOT_NODE_STR
public static final java.lang.String END_NODE_STR
public TreeNode()
public TreeNode(java.lang.String key)
key
- key (word) of the tree nodepublic TreeNode(java.lang.String key, int level)
key
- key (word) of the tree nodelevel
- level of the tree node in the treepublic TreeNode(java.lang.String key, int level, java.util.HashMap<java.lang.String,TreeNode> children)
key
- key (word) of the tree nodelevel
- level of the tree node in the treechildren
- children of the tree nodepublic void SetChildren(java.util.HashMap<java.lang.String,TreeNode> children)
children
- children of the node in HashMap formatpublic java.lang.String GetKey()
public int GetLevel()
public java.util.HashMap<java.lang.String,TreeNode> GetChildren()
public int GetChildrenNo()
public java.lang.String ToString()
public java.lang.String GetDetailString()
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
obj
- the tree node object to be comparedpublic int hashCode()
hashCode
in class java.lang.Object
public static void main(java.lang.String[] args)
args
- arguments of the test driver program Submit a bug or feature
Copyright © 2015 National Library of Medicine