|
|
TreeIterator Interface
|
| boolean
|
addRoot (Object item)
Adds the specified item as the root of
this tree. Throws an exception if the item is
null or the tree in nonempty, else return true. The
current node equals the root, and there is no current parent.
|
| boolean
|
addFirstChild (Object item)
Adds the specified item as the first child
of the current node. Throws an exception if
the item is null or if there is no current node, else returns true. The current parent now equals the old current
node, and the current node now equals the new node.
|
| boolean
|
addRightSibling (Object item)
Adds the specified item as the right sibling
of the current node. Throws an exception if
the item is null or if there is no current node or if the root is current, else returns
true. The current parent does not change, and the current node now equals the new node.
|
| Object
|
getCurrent ()
Returns the item in the current node or null
if there is no current node.
|
| Object
|
getFirstChild ()
If there is no current node then
returns null
Else
current parent = current node
returns item in first child or null if there is none
current node = first child or undefined if there is none
Endif
|
| Object
|
getParent ()
If there is no current parent then
returns null
Else
returns item in current parent
current node = current parent
current parent = current node's parent or undefined if now at root
Endif
|
| Object
|
getRightSibling ()
If there is no current node then
returns null
Else
returns item in right sibling or null if there is none
current node = right sibling or undefined if there is none
Endif
|
| Object
|
getRoot ()
Returns the item in the root or null if the
tree is empty.
|
| boolean
|
hasChild ()
Returns true if the current node has a child
else false. Throws an exception if there is
no current node.
|
| boolean
|
hasCurrentPosition ()
Returns true if there is a current node.
|
| boolean
|
hasParent ()
Returns true if there is a current parent
|
| boolean
|
hasRightSibling ()
Returns true if the current node has a right
sibling. Throws an exception if there is no
current node.
|
| boolean
|
moveTo (int index[])
If the index is invalid then
returns true
current node = specified node
current parent = current node's parent or undefined if there is none
Else
returns false
current node and current parent are now undefined
Else
|
| boolean
|
moveTo (Object item)
If the item is null then
throws an exception
Else if the item is not found then
returns false
current node and current parent are now undefined
Else
returns true
current node = first node in preorder traversal that contains specified item
current parent = current node's parent or undefined if there is none
End
|
| Object
|
removeCurrent ()
If there is no current node then
throws an exception
Else
returns item in current node
removes current node and its children
current node = current node's right sibling or undefined if there is none
Endif
|
| Object
|
setCurrent (Object item)
Returns the item in the current node and
sets the content of the current node to the specified item.
Throws an exception if the specified item is null or if there is no current node.
|