|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectMaze.MazeIterator
private class Maze.MazeIterator
An iterator class that iterates over all the cells in a Maze. This class is implemented using the inner class language feature in Java which allows an inner (as opposed to nested) class to have an implicit reference to the containing class. Thus, any MazeIterator instance implicitly knows with which maze it is associated, and may access the maze's private fields.
Field Summary | |
---|---|
private int |
curCol
Keeps track of the current column over which we are iterating. |
private int |
curRow
Keeps track of the current row over which we are iterating. |
Constructor Summary | |
---|---|
private |
Maze.MazeIterator()
Construct a new MazeIterator. |
Method Summary | |
---|---|
boolean |
hasNext()
Returns true if there are still cells to be iterated over, false otherwise. |
MazeCell |
next()
If hasNext() is true, this returns the next cell in the iteration sequence. |
void |
remove()
The remove function is not implemented in this iterator. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private int curRow
private int curCol
Constructor Detail |
---|
private Maze.MazeIterator()
Method Detail |
---|
public boolean hasNext()
hasNext
in interface java.util.Iterator<MazeCell>
public MazeCell next()
next
in interface java.util.Iterator<MazeCell>
java.util.NoSuchElementException
- Thrown if next() is called when there
are no more elements to be iterated over.public void remove()
remove
in interface java.util.Iterator<MazeCell>
java.lang.UnsupportedOperationException
- Thrown when remove() is called.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |