|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
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(Graphg){ for(Position e : g.edges(Direction.DIRECTED)){ g.reverse(e); } }
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<E> locator()
locator
method is used to
access the second level place holder (used only for complex data structures) such that ...
Locator<E>
contained in the
Position
E element()
element()
returns the
element contained in the position.
Position
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |