Plexus v0.13.1

com.phoenixst.plexus.util
Class SingletonTraverser

java.lang.Object
  extended by com.phoenixst.plexus.util.SingletonTraverser
All Implemented Interfaces:
Traverser, Iterator

public class SingletonTraverser
extends Object
implements Traverser

A Traverser over a single Edge. remove() and removeEdge() delegate to Graph.removeNode( node ) and Graph.removeEdge( edge ) respectively.

An alternate constructor is provided to explicitly make the created Traverser unmodifiable.

Since:
1.0
Version:
$Revision: 1.9 $
Author:
Ray A. Conner

Constructor Summary
SingletonTraverser(Graph graph, Object endpoint, Graph.Edge edge)
          Creates a new modifiable SingletonTraverser.
SingletonTraverser(Object endpoint, Graph.Edge edge)
          Creates a new unmodifiable SingletonTraverser.
 
Method Summary
 Graph.Edge getEdge()
          Returns the Edge which was traversed to get to the last node returned by next(), or null if no Edge was traversed.
 boolean hasNext()
           
 Object next()
           
 void remove()
           
 void removeEdge()
          Removes from the underlying Graph the Edge that would be returned by getEdge() (optional operation).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SingletonTraverser

public SingletonTraverser(Object endpoint,
                          Graph.Edge edge)
Creates a new unmodifiable SingletonTraverser. If this constructor is used, remove() and removeEdge() will throw UnsupportedOperationExceptions.

Parameters:
endpoint - the endpoint of the edge over which the returned Traverser iterates.
edge - the edge over which the returned Traverser iterates.

SingletonTraverser

public SingletonTraverser(Graph graph,
                          Object endpoint,
                          Graph.Edge edge)
Creates a new modifiable SingletonTraverser.

Parameters:
graph - the graph containing the edge over which the returned Traverser iterates.
endpoint - the endpoint of the edge over which the returned Traverser iterates.
edge - the edge over which the returned Traverser iterates.
Method Detail

hasNext

public boolean hasNext()
Specified by:
hasNext in interface Iterator

next

public Object next()
Specified by:
next in interface Iterator

remove

public void remove()
Specified by:
remove in interface Iterator

getEdge

public Graph.Edge getEdge()
Description copied from interface: Traverser
Returns the Edge which was traversed to get to the last node returned by next(), or null if no Edge was traversed. This call can be made only if remove() or removeEdge() has not been called after the last call to next().

Specified by:
getEdge in interface Traverser
Returns:
The Edge which was traversed to get to the last node returned by next(), or null if no Edge was traversed.

removeEdge

public void removeEdge()
Description copied from interface: Traverser
Removes from the underlying Graph the Edge that would be returned by getEdge() (optional operation). If no Edge was traversed (as in the root of a breadth-first search), this method throws a IllegalStateException. This method can be called only once per call to next(). The behavior of a traverser is unspecified if the underlying graph structure is modified while the traversal is in progress in any way other than by calling this method or remove().

Specified by:
removeEdge in interface Traverser

Plexus v0.13.1

See the Plexus project home, hosted by SourceForge.
Copyright ? 1994-2006, by Phoenix Software Technologists, Inc. and others. All Rights Reserved. Use is subject to license terms.