ch.bfh.algo.core.forest
Class GenericForestGraph<E,P extends GenericNode<E,P>>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.AbstractSequentialList<E>
              extended by ch.bfh.algo.core.sequence.GenericLinkedSequence<V,PV>
                  extended by ch.bfh.algo.core.graph.GenericAdjacencyListGraph<Object,E,GenericLink<E,P>,P>
                      extended by ch.bfh.algo.core.forest.GenericForestGraph<E,P>
All Implemented Interfaces:
Container<E>, GenericContainer<E,P>, GenericForest<E,P>, GenericGraph<Object,E,GenericLink<E,P>,P>, GenericSequence<E,P>, Forest<E>, Graph<Object,E>, Sequence<E>, Iterable<E>, Collection<E>, List<E>
Direct Known Subclasses:
DefaultForest, GenericBinaryForestGraph

public class GenericForestGraph<E,P extends GenericNode<E,P>>
extends GenericAdjacencyListGraph<Object,E,GenericLink<E,P>,P>
implements GenericForest<E,P>


Field Summary
 
Fields inherited from class ch.bfh.algo.core.graph.GenericAdjacencyListGraph
factory
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
GenericForestGraph(ForestFactory<P> factory)
           
 
Method Summary
 PositionList<E,P> children(Position<?> parent)
          Returns the list of the children of a given node.
 void cut(P child)
           
 void cut(Position<?> child)
          Removes the relation between the given node (child) and its parent.
 E deleteVertex(P node)
           
protected  P insertBetween(P previous, P next, E element, P position)
           
 void link(Position<?> parent, Position<?> child)
          Creates a link between parent and child.
 void link(P parent, P child)
           
 void linkAfter(Position<?> sibling, Position<?> node)
          Inserts node in the list of children of the parent of sibling.
 void linkAfter(P sibling, P node)
           
 void linkBefore(Position<?> sibling, Position<?> node)
          Inserts node in the list of children of the parent of sibling.
 void linkBefore(P sibling, P node)
           
 P parent(Position<?> child)
          Returns the parent of the given node.
 PositionList<E,P> roots()
          Returns the list of the roots contained in the forest.
 
Methods inherited from class ch.bfh.algo.core.graph.GenericAdjacencyListGraph
adjacentVertices, adjacentVertices, delete, deleteEdge, deleteEdge, deleteVertex, destination, destination, detach, detachVertex, edgeElement, edgeElement, edgeElements, edges, edges, getFactory, incidentEdges, incidentEdges, insertAfter, insertBefore, insertEdge, insertEdge, insertEdge, insertVertex, isDirected, isDirected, opposite, opposite, origin, origin, positionListIterator, positionListIterator, replaceEdge, replaceVertex, reverse, reverse, setDestination, setDestination, setDirected, setDirected, setOrigin, setOrigin, setOriginAfter, setOriginBefore, setUndirected, setUndirected, swapEdge, swapVertex, vertexElement, vertexElements, vertices
 
Methods inherited from class ch.bfh.algo.core.sequence.GenericLinkedSequence
after, after, before, before, delete, element, element, encloses, encloses, first, head, insert, insert, insertAfter, insertBefore, insertBetween, last, listIterator, position, positionIterator, rank, rank, replace, replace, size, swap, swap, tail, validate
 
Methods inherited from class java.util.AbstractSequentialList
add, addAll, get, iterator, remove, set
 
Methods inherited from class java.util.AbstractList
add, clear, equals, hashCode, indexOf, lastIndexOf, listIterator, removeRange, subList
 
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface ch.bfh.algo.core.GenericContainer
insert, positionIterator
 
Methods inherited from interface ch.bfh.algo.Container
delete, element, encloses, replace, swap
 
Methods inherited from interface java.util.Collection
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray
 
Methods inherited from interface ch.bfh.algo.Container
delete, element, encloses, replace, swap
 
Methods inherited from interface java.util.Collection
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray
 
Methods inherited from interface java.util.List
add, add, addAll, addAll, clear, contains, containsAll, equals, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, remove, remove, removeAll, retainAll, set, subList, toArray, toArray
 

Constructor Detail

GenericForestGraph

public GenericForestGraph(ForestFactory<P> factory)
Method Detail

insertBetween

protected P insertBetween(P previous,
                          P next,
                          E element,
                          P position)
Overrides:
insertBetween in class GenericAdjacencyListGraph<Object,E,GenericLink<E,P extends GenericNode<E,P>>,P extends GenericNode<E,P>>

deleteVertex

public E deleteVertex(P node)
Overrides:
deleteVertex in class GenericAdjacencyListGraph<Object,E,GenericLink<E,P extends GenericNode<E,P>>,P extends GenericNode<E,P>>

link

public void link(Position<?> parent,
                 Position<?> child)
Description copied from interface: Forest
Creates a link between parent and child. child is inserted in the list of children of parent and parent becomes its parent.

Specified by:
link in interface Forest<E>
Parameters:
parent - the node that will be the parent
child - the node that will be the child

link

public void link(P parent,
                 P child)

linkAfter

public void linkAfter(Position<?> sibling,
                      Position<?> node)
Description copied from interface: Forest
Inserts node in the list of children of the parent of sibling. node is inserted just after sibling in the list. The parent of sibling becomes the new parent of node.

Specified by:
linkAfter in interface Forest<E>
Parameters:
sibling - the future sibling of node
node - the node that will be inserted

linkAfter

public void linkAfter(P sibling,
                      P node)

linkBefore

public void linkBefore(Position<?> sibling,
                       Position<?> node)
Description copied from interface: Forest
Inserts node in the list of children of the parent of sibling. node is inserted just before sibling in the list. The parent of sibling becomes the new parent of node.

Specified by:
linkBefore in interface Forest<E>
Parameters:
sibling - the future sibling of node
node - the node that will be inserted

linkBefore

public void linkBefore(P sibling,
                       P node)

cut

public void cut(Position<?> child)
Description copied from interface: Forest
Removes the relation between the given node (child) and its parent. child becomes a new root of the forest.

Specified by:
cut in interface Forest<E>
Parameters:
child - the node to be transformed into a root.

cut

public void cut(P child)

roots

public PositionList<E,P> roots()
Description copied from interface: Forest
Returns the list of the roots contained in the forest. I.e. all the nodes without parent.

Specified by:
roots in interface GenericForest<E,P extends GenericNode<E,P>>
Specified by:
roots in interface Forest<E>
Returns:
the list containing all roots.

parent

public P parent(Position<?> child)
Description copied from interface: Forest
Returns the parent of the given node. We get a child and return its parent

Specified by:
parent in interface GenericForest<E,P extends GenericNode<E,P>>
Specified by:
parent in interface Forest<E>
Parameters:
child - the node we are looking at
Returns:
the parent of child.

children

public PositionList<E,P> children(Position<?> parent)
Description copied from interface: Forest
Returns the list of the children of a given node. We receive a parent node and return the list of its children.

Specified by:
children in interface GenericForest<E,P extends GenericNode<E,P>>
Specified by:
children in interface Forest<E>
Parameters:
parent - the node we are looking at
Returns:
the list of all the children of parent.