de.rwth.utils
Interface TreeIterator

All Superinterfaces:
java.util.Iterator, java.util.ListIterator
All Known Implementing Classes:
AbstractTreeIterator

public interface TreeIterator
extends java.util.ListIterator

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.

Version:
$Id: TreeIterator.java,v 1.2 2002/09/17 06:53:53 mohnen Exp $
Author:
Markus Mohnen

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

hasCurrent

public boolean hasCurrent()
Returns true iff there is a current element available. In other words, it will return false iff no call to getNext has been done.
Returns:
true iff there is a current element available

current

public java.lang.Object current()
                         throws java.util.NoSuchElementException
Returns the current element.
Returns:
The current Object
Throws:
java.util.NoSuchElementException - if there is no current element.

currentIndex

public int currentIndex()
Returns the index of the current element among the children of the current parent. The first element after a call to next has index 0.
Returns:
the index of the current element of -1 if there is no current element.

hasLeft

public boolean hasLeft()
Checks if there is an element to the left in the tree. After a call to the method next this method will always return false.
Returns:
true iff there is an element to the left in the tree.

hasRight

public boolean hasRight()
Checks if there is an element to the right in the tree.
Returns:
true iff there is an element to the right in the tree.

left

public java.lang.Object left()
                      throws java.util.NoSuchElementException
Returns the element to the left.
Returns:
the Object to the left.
Throws:
java.util.NoSuchElementException - if there is no element to the left.

right

public java.lang.Object right()
                       throws java.util.NoSuchElementException
Returns the element to the right.
Returns:
the Object to the right.
Throws:
java.util.NoSuchElementException - if there is no element to the right

leftIndex

public int leftIndex()
Returns the index of the left element among the children of the current parent.
Returns:
index of the left element; -1 if there is no element to the left

rightIndex

public int rightIndex()
Returns the index of the right element among the children of the current parent.
Returns:
index of the right element; -1 if there is no element to the right

position

public Position position()
Gets the current position in this tree.
Returns:
a value of type Position