ch.bfh.algo
Interface Position<E>

All Known Subinterfaces:
GenericPosition<E,P>
All Known Implementing Classes:
ArrayPosition, BinaryNode, ConcretePosition, Edge, GenericArrayPosition, GenericBinaryNode, GenericEdge, GenericLink, GenericLinkedPosition, GenericNode, GenericVertex, LinkedPosition, Node, ObserverPosition, Vertex

public interface Position<E>

The Position interface is used as a placeholder in all the containers (for instance Sequence, Forest, or Graph). It contains an element and does not have any other functionalities. It is passed as a parameter to the container for accessing its internal functionalities. One will use this interface to implement efficiently methods that could not be done without this feature. In the following example, we use two positions to visit a sequence

Position<Integer> pos1 = seq.first();
while(pos1!=seq.last()){
    pos2=seq.after(pos1);
    if( pos1.element()> pos2.element()){
        Integer tmp = pos1.element();
        seq.replace(pos1,pos2.element());
        seq.replace(pos2,tmp);
    }
}
 
We will also use Positions to visit a graph (we reverse all edges of the given graph):
    public static void reverseAllEdges(Graph g){
        for(Position e : g.edges(Direction.DIRECTED)){
            g.reverse(e);
        }
    }
 

Version:
1.0
Author:
Juerg Kraehenbuehl (code) and Emmanuel Benoist (Javadoc)

Method Summary
 E element()
          The method element() returns the element contained in the position.
 Locator<E> locator()
          The locator method is used to access the second level place holder (used only for complex data structures) such that ...
 

Method Detail

locator

Locator<E> locator()
The locator method is used to access the second level place holder (used only for complex data structures) such that ...

Returns:
the Locator<E> contained in the Position

element

E element()
The method element() returns the element contained in the position.

Returns:
E the element contained in the Position