structure
Class GraphListAIterator

java.lang.Object
  |
  +--structure.AbstractIterator
        |
        +--structure.GraphListAIterator
All Implemented Interfaces:
java.util.Enumeration, java.util.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());
      }
 


Field Summary
protected  java.util.Iterator edges
           
protected  java.lang.Object vertex
           
 
Constructor Summary
GraphListAIterator(java.util.Iterator i, java.lang.Object v)
           
 
Method Summary
 java.lang.Object get()
          Returns the value currently being considered by the AbstractIterator.
 boolean hasNext()
          Returns true if the iterator has more elements to visit.
 java.lang.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 structure.AbstractIterator
hasMoreElements, nextElement, remove, value
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

edges

protected java.util.Iterator edges

vertex

protected java.lang.Object vertex
Constructor Detail

GraphListAIterator

public GraphListAIterator(java.util.Iterator i,
                          java.lang.Object v)
Parameters:
i -
v -
Method Detail

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.

Specified by:
reset in class AbstractIterator

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.

Specified by:
hasNext in interface java.util.Iterator
Specified by:
hasNext in class AbstractIterator
Returns:
True if more adj. vertices to traverse
See Also:
AbstractIterator.hasMoreElements()

next

public java.lang.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.

Specified by:
next in interface java.util.Iterator
Specified by:
next in class AbstractIterator
Returns:
The next adjacent vertex
See Also:
AbstractIterator.hasMoreElements(), AbstractIterator.value()

get

public java.lang.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.

Specified by:
get in class AbstractIterator
Returns:
The current adj. vertex