|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--jdsl.core.ref.PreOrderIterator
The preorder iterator gives a preorder iteration of the 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 | |
PreOrderIterator(InspectableBinaryTree tree)
Constructs a new PreOrderIterator to iterate over the given binary tree Puts a reference to each position into the array -- takes O(N) time where N = the number of positions in the tree |
|
PreOrderIterator(InspectableTree tree)
Constructs a new PreOrderIterator to iterate over the given general tree Puts a reference to each position into the array -- takes O(N) time where N = the number of positions in the tree |
Method Summary | |
java.lang.Object |
element()
Takes O(1) time |
boolean |
hasNext()
Takes O(1) time |
java.lang.Object |
nextObject()
|
Position |
nextPosition()
Takes O(1) time |
java.lang.Object |
object()
|
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 PreOrderIterator(InspectableBinaryTree tree)
tree
- The tree to iterate overpublic PreOrderIterator(InspectableTree tree)
tree
- The tree to iterate overMethod Detail |
public boolean hasNext()
hasNext
in interface ObjectIterator
jdsl.core.api.ObjectIterator
public java.lang.Object nextObject()
nextObject
in interface ObjectIterator
jdsl.core.api.ObjectIterator
java.util.NoSuchElementException
- if iterator has moved past
the last objectpublic java.lang.Object object()
object
in interface ObjectIterator
jdsl.core.api.ObjectIterator
java.util.NoSuchElementException
- When the iterator is in its
initial, before-the-first-object statepublic void reset()
reset
in interface ObjectIterator
public Position nextPosition()
nextPosition
in interface PositionIterator
jdsl.core.api.PositionIterator
java.util.NoSuchElementException
- if iterator has moved past
the last position to be seenpublic Position position() throws java.util.NoSuchElementException
position
in interface PositionIterator
jdsl.core.api.PositionIterator
java.util.NoSuchElementException
- When the iterator is in its
initial, before-the-first-position statepublic java.lang.Object element() throws java.util.NoSuchElementException
element
in interface PositionIterator
jdsl.core.api.PositionIterator
java.util.NoSuchElementException
- When the iterator is in its
initial, before-the-first-position state
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |