ch.elca.el4j.core.io.support
Class DefaultModuleSorter

java.lang.Object
  extended by ch.elca.el4j.core.io.support.DefaultModuleSorter
All Implemented Interfaces:
ModuleSorter

public class DefaultModuleSorter
extends Object
implements ModuleSorter

This class sorts a list of unordered modules using their dependency information.

The algorithm computes the children of each module and the set of root nodes, i.e. nodes without dependencies. Then it removes the next root r from the root list and adds it to the sorted modules list. The algorithm then iterates over all the children of r, removing the dependency to r. If a children has no more unsatisfied dependencies, it's added to the list of root nodes. The algorithm performs this step as long as there are nodes in the root nodes list. Finally, it checks that there are no more unsatisfied dependencies, which could happen if there are cycles in the dependency graph.

Author:
Andreas Bur (ABU), Martin Zeltner (MZE)
File-location:
DefaultModuleSorter
Last check-in date:
2009-08-04 14:25:40 +0200 (Di, 04. Aug 2009) by swismer for revision 3874

Constructor Summary
DefaultModuleSorter()
           
 
Method Summary
 Module[] sortModules(Module[] modules)
          Sorts a list of unordered modules using their dependency information into a list that respects the partial order.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultModuleSorter

public DefaultModuleSorter()
Method Detail

sortModules

public Module[] sortModules(Module[] modules)
Sorts a list of unordered modules using their dependency information into a list that respects the partial order.

Specified by:
sortModules in interface ModuleSorter
Parameters:
modules - The modules to sort.
Returns:
Returns a list of modules that preserves the partial order defined by dependency information.


Copyright © 2005-2011 ELCA. All Rights Reserved.