structure
Class GraphListAIterator
java.lang.Object
|
+--structure.AbstractIterator
|
+--structure.GraphListAIterator
- All Implemented Interfaces:
- Enumeration, Iterator
- class GraphListAIterator
- extends AbstractIterator
An adjacent vertex iterator. Adjacent vertices
(those on destination of edge, if directed) are considered,
but not in any guaranteed order.
Typical use:
Graph g = new GraphList();
// ...list gets built up...
Iterator ai = g.neighbors(someVertex);
while (ai.hasNext()
)
{
System.out.println(ai.next()
);
}
Method Summary |
Object |
get()
Returns the value currently being considered by the AbstractIterator. |
boolean |
hasNext()
Returns true if the iterator has more elements to visit. |
Object |
next()
Moves, bumps, or "increments" the iterator along the traversal;
returns the next value considered. |
void |
reset()
Reset iterator to the beginning of the structure. |
Methods inherited from class java.lang.Object |
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait |
edges
protected Iterator edges
vertex
protected Object vertex
GraphListAIterator
public GraphListAIterator(Iterator i,
Object v)
- Parameters:
i
- v
-
reset
public void reset()
- Description copied from class:
AbstractIterator
- Reset iterator to the beginning of the structure.
This method is not required of
Iterator
or
Enumeration
implementation, but some traversals
may allow efficient multi-pass implementations with little
overhead. The user is encouraged to implement this method.
- Overrides:
reset
in class AbstractIterator
- Postcondition:
- resets iterator
hasNext
public boolean hasNext()
- Description copied from class:
AbstractIterator
- Returns true if the iterator has more elements to visit.
The method
hasMoreElements
is an
Enumeration
-required call to this method. The user
should override only this method.
- Overrides:
hasNext
in class AbstractIterator
- Postcondition:
- returns true if more adj. vertices to traverse
- Returns:
- True if more adj. vertices to traverse
next
public Object next()
- Description copied from class:
AbstractIterator
- Moves, bumps, or "increments" the iterator along the traversal;
returns the next value considered.
This method should only be called if the iterator has a next value.
To get a value from an iterator multiple times, use the
value
method.
This method is preferred over the nextElement
method.
- Overrides:
next
in class AbstractIterator
- Precondition:
- hasNext
- Postcondition:
- returns the next adjacent vertex
- Returns:
- The next adjacent vertex
get
public Object get()
- Description copied from class:
AbstractIterator
- Returns the value currently being considered by the AbstractIterator.
This method is required by neither
Iterator
nor
Enumeration
. This method should be implemented,
however, to provide better support for for
-loops.
- Overrides:
get
in class AbstractIterator
- Precondition:
- hasNext
- Postcondition:
- returns the current adj. vertex
- Returns:
- The current adj. vertex