本文整理匯總了Java中org.openide.util.Utilities.topologicalSort方法的典型用法代碼示例。如果您正苦於以下問題:Java Utilities.topologicalSort方法的具體用法?Java Utilities.topologicalSort怎麽用?Java Utilities.topologicalSort使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.openide.util.Utilities
的用法示例。
在下文中一共展示了Utilities.topologicalSort方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: simulateJaveleonReload
import org.openide.util.Utilities; //導入方法依賴的package包/類
/** Only for use from Javeleon code. */
public List<Module> simulateJaveleonReload(Module moduleToReload) throws IllegalArgumentException {
Set<Module> transitiveDependents = new HashSet<Module>(20);
addToJaveleonDisableList(transitiveDependents, moduleToReload);
Map<Module,List<Module>> deps = Util.moduleDependencies(transitiveDependents, modulesByName, getProvidersOf());
try {
LinkedList<Module> orderedForEnabling = new LinkedList<Module>();
for (Module m : Utilities.topologicalSort(transitiveDependents, deps)) {
if (m != moduleToReload) {
orderedForEnabling.addFirst(m);
}
}
return orderedForEnabling;
} catch (TopologicalSortException ex) {
return new ArrayList<Module>(transitiveDependents);
}
}
示例2: sort
import org.openide.util.Utilities; //導入方法依賴的package包/類
private Collection<ConnectedProperty> sort() {
List<ConnectedProperty> sortedValues = null;
try {
sortedValues = Utilities.topologicalSort(properties.values(), getEdges());
} catch (TopologicalSortException tse) {
Set[] sets = tse.topologicalSets();
sortedValues = new ArrayList<ConnectedProperty>();
for (int i = 0; i < sets.length; i++) {
for (Iterator it = sets[i].iterator(); it.hasNext();) {
sortedValues.add((ConnectedProperty)it.next());
}
}
}
if(sortedValues!=null) {
Collections.reverse(sortedValues);
return sortedValues;
}
// something went wrong, let's fall back
// on the unsorted values
return properties.values();
}
示例3: simulateDisable
import org.openide.util.Utilities; //導入方法依賴的package包/類
/** Simulate what would happen if a set of modules were to be disabled.
* None of the listed modules may be autoload modules, nor eager, nor currently disabled, nor fixed.
* The returned set will list all modules that would actually be disabled,
* meaning the listed modules, plus any currently enabled but unlisted modules
* (including autoloads) that require some listed modules, plus any autoloads
* which would no longer be needed as they were only required by modules
* otherwise disabled.
* Provide-require pairs count for purposes of disablement: if the set of
* requested modules includes all remaining enabled providers of some token,
* and modules requiring that token will need to be disabled as well.
* Modules are returned in an order in which they could be disabled (where
* dependent modules are always disabled before base modules).
*/
public List<Module> simulateDisable(Set<Module> modules) throws IllegalArgumentException {
if (modules.isEmpty()) {
return Collections.<Module>emptyList();
}
// XXX also optimize for modules.size == 1
// Probably not a very efficient algorithm. But it probably does not need to be.
Set<Module> willDisable = new TreeSet<Module>(new CodeNameBaseComparator());
for (Module m : modules) {
if (m.isAutoload()) throw new IllegalArgumentException("Cannot disable autoload: " + m); // NOI18N
if (m.isEager()) throw new IllegalArgumentException("Cannot disable eager module: " + m); // NOI18N
if (m.isFixed()) throw new IllegalArgumentException("Cannot disable fixed module: " + m); // NOI18N
if (! m.isEnabled()) throw new IllegalArgumentException("Already disabled: " + m); // NOI18N
addToDisableList(willDisable, m);
}
Set<Module> stillEnabled = new HashSet<Module>(getEnabledModules());
stillEnabled.removeAll(willDisable);
while (searchForUnusedAutoloads(willDisable, stillEnabled)) {/* search again */}
Map<Module,List<Module>> deps = Util.moduleDependencies(willDisable, modulesByName, getProvidersOf());
try {
return Utilities.topologicalSort(willDisable, deps);
} catch (TopologicalSortException ex) {
// Again, don't know what to do exactly, so give up and just turn them off.
if (PRINT_TOPOLOGICAL_EXCEPTION_STACK_TRACES) {
Util.err.log(Level.WARNING, null, ex);
}
Util.err.warning("Cyclic module dependencies, will turn them off in a random order: " + deps); // NOI18N
return new ArrayList<Module>(willDisable);
}
}
示例4: reverseSourceRootsInOrder
import org.openide.util.Utilities; //導入方法依賴的package包/類
private List<URL> reverseSourceRootsInOrder(CompilationInfo info, URL thisRoot, FileObject thisRootFO, Map<URL, List<URL>> sourceDeps, Map<URL, List<URL>> binaryDeps, Map<URL, List<URL>> rootPeers, boolean interactive, boolean isSourceRoot) {
if (reverseSourceRootsInOrderOverride != null) {
return reverseSourceRootsInOrderOverride;
}
Set<URL> sourceRootsSet;
if (sourceDeps.containsKey(thisRoot)) {
sourceRootsSet = findReverseSourceRoots(thisRoot, sourceDeps, rootPeers, info.getFileObject());
} else {
sourceRootsSet = new HashSet<URL>();
for (URL binary : findBinaryRootsForSourceRoot(thisRootFO, binaryDeps, isSourceRoot)) {
List<URL> deps = binaryDeps.get(binary);
if (deps != null) {
sourceRootsSet.addAll(deps);
}
}
}
List<URL> sourceRoots;
try {
sourceRoots = new LinkedList<URL>(Utilities.topologicalSort(sourceDeps.keySet(), sourceDeps));
} catch (TopologicalSortException ex) {
if (interactive) {
// Exceptions.attachLocalizedMessage(ex,NbBundle.getMessage(GoToImplementation.class, "ERR_CycleInDependencies"));
Exceptions.printStackTrace(ex);
} else {
LOG.log(Level.FINE, null, ex);
}
return null;
}
sourceRoots.retainAll(sourceRootsSet);
Collections.reverse(sourceRoots);
return sourceRoots;
}
示例5: reverseSourceRootsInOrder
import org.openide.util.Utilities; //導入方法依賴的package包/類
private List<URL> reverseSourceRootsInOrder(CompilationInfo info, URL thisSourceRoot, FileObject thisSourceRootFO, Map<URL, List<URL>> sourceDeps, Map<URL, List<URL>> binaryDeps, Map<URL, List<URL>> rootPeers, boolean interactive) {
if (reverseSourceRootsInOrderOverride != null) {
return reverseSourceRootsInOrderOverride;
}
final Set<URL> sourceRootsSet = new HashSet<>();
if (sourceDeps.containsKey(thisSourceRoot)) {
sourceRootsSet.addAll(findReverseSourceRoots(thisSourceRoot, sourceDeps, rootPeers, info.getFileObject()));
}
for (URL binary : findBinaryRootsForSourceRoot(thisSourceRootFO, binaryDeps)) {
final List<URL> deps = binaryDeps.get(binary);
if (deps != null) {
sourceRootsSet.addAll(deps);
}
}
List<URL> sourceRoots;
try {
sourceRoots = new LinkedList<URL>(Utilities.topologicalSort(sourceDeps.keySet(), sourceDeps));
} catch (TopologicalSortException ex) {
if (interactive) {
Exceptions.attachLocalizedMessage(ex,NbBundle.getMessage(GoToImplementation.class, "ERR_CycleInDependencies"));
Exceptions.printStackTrace(ex);
} else {
LOG.log(Level.FINE, null, ex);
}
return null;
}
sourceRoots.retainAll(sourceRootsSet);
Collections.reverse(sourceRoots);
return sourceRoots;
}