|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
The TreeIterator
interface provides a means for traversing a
tree. The methods inherited from the ListIterator
interface traverse
up and down in the tree, the new methods declared here move to the left and right.
Method Summary | |
java.lang.Object |
current()
Returns the current element. |
int |
currentIndex()
Returns the index of the current element among the children of the current parent. |
boolean |
hasCurrent()
Returns true iff there is a current element available. |
boolean |
hasLeft()
Checks if there is an element to the left in the tree. |
boolean |
hasRight()
Checks if there is an element to the right in the tree. |
java.lang.Object |
left()
Returns the element to the left. |
int |
leftIndex()
Returns the index of the left element among the children of the current parent. |
Position |
position()
Gets the current position in this tree. |
java.lang.Object |
right()
Returns the element to the right. |
int |
rightIndex()
Returns the index of the right element among the children of the current parent. |
Methods inherited from interface java.util.ListIterator |
add, hasNext, hasPrevious, next, nextIndex, previous, previousIndex, remove, set |
Method Detail |
public boolean hasCurrent()
true
iff there is a current element available. In other
words, it will return false iff no call to getNext
has been done.true
iff there is a current element availablepublic java.lang.Object current() throws java.util.NoSuchElementException
Object
java.util.NoSuchElementException
- if there is no current element.public int currentIndex()
next
has index 0.-1
if there is no
current element.public boolean hasLeft()
next
this method will always return false
.true
iff there is an element to the left in the tree.public boolean hasRight()
true
iff there is an element to the right in the tree.public java.lang.Object left() throws java.util.NoSuchElementException
Object
to the left.java.util.NoSuchElementException
- if there is no element to the left.public java.lang.Object right() throws java.util.NoSuchElementException
Object
to the right.java.util.NoSuchElementException
- if there is no element to the rightpublic int leftIndex()
-1
if there is no element to the
leftpublic int rightIndex()
-1
if there is no element to
the rightpublic Position position()
position
in this tree.Position
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |