net.sourceforge.esw.graph
Interface IGraphVisitor


public interface IGraphVisitor

Provides a way to visit all children of an INode instance.

This is the Visitor of the Visitor design pattern.

Visits the children in insertion order. The default implementation performs a shallow operation, visiting this INode instance's children and no further child generations.

Example:
Print the children, in insertion order, of the INode instance being visited. As this example shows, it is often convenient to implement the visitor as an anonymous inner class.

 IGraphVisitor visitor = new IGraphVisitor () {
   public boolean visit( INode aNode ) {
      System.out.println( aNode );
      return true;
   }
 };

 node.acceptVisitor( visitor );
 

See Also:
INode

Method Summary
 boolean visit(INode aElement)
          Invoked during a visit by an INode instance during its acceptVisitor method.
 

Method Detail

visit

public boolean visit(INode aElement)
Invoked during a visit by an INode instance during its acceptVisitor method. The specified parameter identifies what we are currently visiting: a specific child, of that INode instance. The returned boolean value can be used to end the visit early. This can be useful to avoid unnecessary effort when searching for a specific child, for instance, and that child is located early before reaching the list of children.
Parameters:
aElement - a child of the visited INode instance.
Returns:
whether to visit the next element of the graph.


Copyright 2002 Free Software Foundation. All Rights Reserved.