Package edu.ksu.cis.viewer
Class Node
java.lang.Object
edu.ksu.cis.viewer.Node
- All Implemented Interfaces:
Serializable
,Cloneable
The objects used as the nodes of trees in the
BinaryTree
class.
The contents of a Node are represented
by a String. In addition, each Node has an int
tag and a color.
A Node is immutable.- Author:
- Rod Howell (rhowell@ksu.edu)
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a black Node with the given contents and a tag of 0.Constructs a black Node with the given contents and tag.Constructs a Node of the given color with the given contents and tag.Constructs a Node of the given color with the given contents and a tag of 0. -
Method Summary
-
Constructor Details
-
Node
Constructs a black Node with the given contents and a tag of 0.- Parameters:
s
- the contents of the node- Throws:
NullPointerException
- ifs
isnull
-
Node
Constructs a black Node with the given contents and tag.- Parameters:
s
- the contents of the Nodetag
- the tag- Throws:
NullPointerException
- ifs
isnull
-
Node
Constructs a Node of the given color with the given contents and a tag of 0.- Parameters:
s
- the contents of the Nodecol
- the color of the Node- Throws:
NullPointerException
- if eithers
orcol
isnull
-
Node
Constructs a Node of the given color with the given contents and tag.- Parameters:
s
- the contents of the Nodetag
- the tagcol
- the color of the Node- Throws:
NullPointerException
- if eithers
orcol
isnull
-
-
Method Details
-
getContents
Returns the contents of the Node.- Returns:
- the contents of this node
-
getTag
public int getTag()Returns the tag of the Node.- Returns:
- the tag for this node
-
getColor
Returns the color of the Node.- Returns:
- the color of this node
-
clone
Because this structure is immutable, this method simply returns the node itself.
-