|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.toronto.cs.util.NaryTree
public class NaryTree
This is an N-ary Tree class.
Field Summary | |
---|---|
protected java.util.Map |
children
|
protected java.lang.Object |
data
|
Constructor Summary | |
---|---|
NaryTree()
Constructs a new NaryTree assigning null to Data and no children. |
|
NaryTree(java.lang.Object d)
Constructs a new NaryTree contaning the specified Object as its data and no children. |
|
NaryTree(java.lang.Object d,
java.util.Map c)
Constructs a new NaryTree with given data as well as the children. |
Method Summary | |
---|---|
boolean |
existChild(java.lang.Object name)
Checks whether such a child exists. |
NaryTree |
getChild(java.lang.Object id)
Gets the child with the specified id. |
java.util.Map |
getChildren()
Retrieves the Map of children. |
java.lang.Object |
getData()
Retrieves the data from the NaryTree. |
int |
getNumChildren()
Gets the number of children that this tree node has. |
void |
setChild(java.lang.Object id,
NaryTree child)
Changes the nth child of the NaryTree. |
void |
setChildren(java.util.Map c)
Assigns a new Map of children. |
void |
setData(java.lang.Object d)
Changes the data in the NaryTree. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.lang.Object data
protected java.util.Map children
Constructor Detail |
---|
public NaryTree()
public NaryTree(java.lang.Object d)
d
- -- data to be stored in the root node.public NaryTree(java.lang.Object d, java.util.Map c)
d
- -- data to be stored in the root node.c
- -- a Map contaning children (of type NaryTree).Method Detail |
---|
public java.lang.Object getData()
public int getNumChildren()
public java.util.Map getChildren()
public NaryTree getChild(java.lang.Object id)
public void setData(java.lang.Object d)
public void setChild(java.lang.Object id, NaryTree child)
public void setChildren(java.util.Map c)
c
- -- a Map of children.public boolean existChild(java.lang.Object name)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |