|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectMaze.NeighborIterator
private class Maze.NeighborIterator
An iterator class that iterates over all neighbors that can be reached from the cell the iterator was created for. As for MazeIterator, we use an inner class so that NeighborIterator is associated with a particular instance of Maze.
Field Summary | |
---|---|
private Direction |
curWall
The current wall we are examining. |
private int |
numNeighborsFound
The number of neighbors we have found for this cell so far. |
private MazeCell |
refCell
The cell over whose neighbors we are iterating. |
Constructor Summary | |
---|---|
Maze.NeighborIterator(MazeCell cell)
Construct a new NeighborIterator that will iterator over the neighbors of cell |
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 MazeCell refCell
private Direction curWall
private int numNeighborsFound
Constructor Detail |
---|
public Maze.NeighborIterator(MazeCell cell)
cell
cell
- The cell whose neighbors this iterator will iterate over.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 |