gishur.graph.core
Class TraverseCursor

java.lang.Object
  |
  +--gishur.core.CursorAdapter
        |
        +--gishur.graph.core.GraphCursor
              |
              +--gishur.graph.core.TraverseCursor
All Implemented Interfaces:
Cursor, java.util.Enumeration

public final class TraverseCursor
extends GraphCursor

A traversal-cursor, that extends GraphCursor and uses a given TraverseAlgorithmCursor for navigation.

For an example we use the BFSCursor class that implements the Breath-First-Search algorithm:

 BFSCursor bfs=new BFCursor(graph);
 TraverseCursor cursor=new TraverseCursor(bfs);
 for (cursor.top();cursor.valid();cursor.next()) {
  ... // do something
 }

Version:
1.0
Author:
Thomas Wolf

Constructor Summary
TraverseCursor(TraverseAlgorithmCursor cursor)
          Constructs a new TraverseCursor that uses the traversal algorithm specified via the given TraverseAlgorithmCursor.
 
Method Summary
 java.lang.Object element()
          Returns the element to which this Cursor points at the moment.
 Graph graph()
          Returns the Graph, on which the Cursor works.
 void invalidate()
          Sets the Cursor to an invalid position.
 int length()
          Returns the number of elements in the underlying structure of this Cursor.
 void relative(int step)
          Moves the Cursor step positions within the underlying structure.
 java.lang.String toString()
          Overrides java.lang.Object.toString().
 boolean valid()
          Checks if the Cursor's actual position is valid.
 
Methods inherited from class gishur.graph.core.GraphCursor
addFilter, edge, filter, graphElement, isEdge, isNode, node, removeFilter, set, validElement
 
Methods inherited from class gishur.core.CursorAdapter
bottom, getBookmark, hasMoreElements, next, next, nextElement, prev, prev, set, set, top
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TraverseCursor

public TraverseCursor(TraverseAlgorithmCursor cursor)
Constructs a new TraverseCursor that uses the traversal algorithm specified via the given TraverseAlgorithmCursor.
Parameters:
cursor - the TraverseAlgorithmCursor used for navigation
Method Detail

toString

public java.lang.String toString()
Overrides java.lang.Object.toString().
Overrides:
toString in class java.lang.Object
See Also:
Object.toString()

graph

public Graph graph()
Returns the Graph, on which the Cursor works.
Overrides:
graph in class GraphCursor
Returns:
the Graph, on which the Cursor works.

element

public java.lang.Object element()
Returns the element to which this Cursor points at the moment.
Returns:
the element "under" the Cursor

relative

public void relative(int step)
Moves the Cursor step positions within the underlying structure.
Parameters:
step - the number of elements to move

valid

public boolean valid()
Checks if the Cursor's actual position is valid.
Returns:
true, if the Cursor points to a valid position, and false otherwise

invalidate

public void invalidate()
Sets the Cursor to an invalid position.

length

public int length()
Returns the number of elements in the underlying structure of this Cursor.
Returns:
the number of elements in the underlying structure