de.cau.cs.kieler.core.util
Interface IDependencyGraph<S extends Comparable<S>,T extends IDepending<S>>

Type Parameters:
S - the identifier type
T - the object type
All Known Implementing Classes:
DependencyGraph

public interface IDependencyGraph<S extends Comparable<S>,T extends IDepending<S>>

The interface for graph structures that express and resolve object dependencies.

Rating red

Nested Class Summary
static interface IDependencyGraph.DerivationDetail<T,R>
          The interface for specifing the details of an object derivation.
 
Method Summary
 boolean add(T object)
          Adds an object to the graph if all dependencies can be resolved.
 List<T> addAll(Collection<T> objects)
          Adds a collection of objects to the graph and tries to resolve dependencies.
Returns a list of objects that could not be added cause they had missing dependencies or were part of a cycle.
 List<T> dependencySort(List<T> objects)
          Returns a sorted list of the objects so that an object that depends on another object precedes it in the list.
<R> R
deriveObject(T object, IDependencyGraph.DerivationDetail<T,R> derivationDetail)
          Derives a new object from an object in the graph, preserving the dependency information.
 T get(S id)
          Returns an object by it's identifier.
 List<T> remove(T object)
          Removes an object from the graph and all objects depending on it.
 

Method Detail

add

boolean add(T object)
Adds an object to the graph if all dependencies can be resolved.

Parameters:
object - the object
Returns:
true if the object was added

remove

List<T> remove(T object)
Removes an object from the graph and all objects depending on it.

Parameters:
object - the object to remove
Returns:
the removed objects

addAll

List<T> addAll(Collection<T> objects)
Adds a collection of objects to the graph and tries to resolve dependencies.
Returns a list of objects that could not be added cause they had missing dependencies or were part of a cycle.

Parameters:
objects - the objects to add
Returns:
the list of objects that could not be added

get

T get(S id)
Returns an object by it's identifier.

Parameters:
id - the identifier
Returns:
the object

dependencySort

List<T> dependencySort(List<T> objects)
Returns a sorted list of the objects so that an object that depends on another object precedes it in the list. Removes objects that are not represented in this graph.

Parameters:
objects - the objects
Returns:
a sorted list respecting dependencies between the objects

deriveObject

<R> R deriveObject(T object,
                   IDependencyGraph.DerivationDetail<T,R> derivationDetail)
Derives a new object from an object in the graph, preserving the dependency information.

Type Parameters:
R - the derivative type
Parameters:
object - the object in the graph
derivationDetail - the details of the derivation
Returns:
the derivative