public class BSTIterator<K>
extends java.lang.Object
implements java.util.Iterator<K>
Modifier and Type | Field and Description |
---|---|
(package private) java.util.Stack<BSTNode<K>> |
stack
Stack to track where the iterator is in the BST
|
Constructor and Description |
---|
BSTIterator(BSTNode<K> n)
Constructs the iterator so that it is initially at the smallest
value in the set.
|
Modifier and Type | Method and Description |
---|---|
boolean |
hasNext()
Returns true iff the iterator has more items.
|
K |
next()
Returns the next item in the iteration.
|
void |
remove()
Not Supported
|
public boolean hasNext()
hasNext
in interface java.util.Iterator<K>
public K next()
next
in interface java.util.Iterator<K>
java.util.NoSuchElementException
- if the iterator has no more itemspublic void remove()
remove
in interface java.util.Iterator<K>