|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjdsl.core.ref.InOrderIterator
The inorder iterator gives an inorder iteration of a binary tree. Creating this iterator takes O(N) where N = the number of positions in the tree, assuming that root, rightChild, leftChild, isInternal are O(1) in the tree implementation. All other methods take O(1) time
Constructor Summary | |
InOrderIterator(InspectableBinaryTree tree)
Constructs a new InOrderIterator to iterate over the given container Puts a reference to each position into the array -- takes O(N) time where N = the number of positions in the container (given assumptions discussed in header) |
Method Summary | |
Object |
element()
Takes O(1) time |
boolean |
hasNext()
Takes O(1) time |
Object |
nextObject()
Takes O(1) time |
Position |
nextPosition()
Takes O(1) time |
Object |
object()
Takes O(1) time |
Position |
position()
Takes O(1) time |
void |
reset()
Takes O(1) time Sets the current node to the first node. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public InOrderIterator(InspectableBinaryTree tree)
tree
- The tree to iterate overMethod Detail |
public boolean hasNext()
hasNext
in interface ObjectIterator
public Object nextObject()
nextObject
in interface ObjectIterator
public Position nextPosition()
nextPosition
in interface PositionIterator
public Object object()
object
in interface ObjectIterator
public Object element() throws NoSuchElementException
element
in interface PositionIterator
NoSuchElementException
- When the iterator is in its
initial, before-the-first-position statepublic Position position() throws NoSuchElementException
position
in interface PositionIterator
NoSuchElementException
- When the iterator is in its
initial, before-the-first-position statepublic void reset()
reset
in interface ObjectIterator
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |