org.openide.util.Utilities.topologicalSort()方法的使用及代码示例

x33g5p2x  于2022-01-31 转载在 其他  
字(6.8k)|赞(0)|评价(0)|浏览(97)

本文整理了Java中org.openide.util.Utilities.topologicalSort()方法的一些代码示例,展示了Utilities.topologicalSort()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utilities.topologicalSort()方法的具体详情如下:
包路径:org.openide.util.Utilities
类名称:Utilities
方法名:topologicalSort

Utilities.topologicalSort介绍

[英]Topologically sort some objects.

There may not be any nulls among the objects, nor duplicates (as per hash/equals), nor duplicates among the edge lists. The edge map need not contain an entry for every object, only if it has some outgoing edges (empty but not null map values are permitted). The edge map shall not contain neither keys nor value entries for objects not in the collection to be sorted, if that happens they will be ignored (since version 7.9).

The incoming parameters will not be modified; they must not be changed during the call and possible calls to TopologicalSortException methods. The returned list will support modifications.

There is a weak stability guarantee: if there are no edges which contradict the incoming order, the resulting list will be in the same order as the incoming elements. However if some elements need to be rearranged, it is not guaranteed that others will not also be rearranged, even if they did not strictly speaking need to be.
[中]对某些对象进行拓扑排序。
对象之间不能有任何空值,也不能有重复项(根据哈希/相等),边缘列表中也不能有重复项。边映射不需要包含每个对象的条目,只有当它有一些输出边时(允许为空但不允许为空的映射值)。对于不在要排序的集合中的对象,边映射不应包含键或值条目,如果发生这种情况,它们将被忽略(从7.9版开始)。
传入参数将不被修改;在调用和可能调用Topological或Exception方法的过程中,不得更改它们。返回的列表将支持修改。
有一个“弱”稳定性保证:如果没有与传入顺序相矛盾的边,那么生成的列表将与传入元素的顺序相同。然而,如果某些元素需要重新排列,则不能保证其他元素也不会被重新排列,即使严格来说它们不需要被重新排列。

代码示例

代码示例来源:origin: org.netbeans.api/org-openide-util

List<Set> listResult = Utilities.topologicalSort(sets, edgesBetweenSets);
  result = listResult.toArray(new Set[0]);
} catch (TopologicalSortException ex) {

代码示例来源:origin: org.netbeans.api/org-openide-filesystems

} else {
  try {
    return Utilities.topologicalSort(children, edges);
  } catch (TopologicalSortException x) {
    if (logWarnings) {

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-vmd-model

private void createTopology () {
  HashSet<PresenterListener> unsortedSet = new HashSet<PresenterListener> ();
  HashMap<PresenterListener, HashSet<PresenterListener>> _dependencyMap = new HashMap<PresenterListener, HashSet<PresenterListener>> ();
  for (DependencyItem item : dependencies)
    item.setupTopology (unsortedSet, _dependencyMap);
  try {
    this.topology = Utilities.topologicalSort (unsortedSet, _dependencyMap);
    this.dependencyMap = _dependencyMap;
  } catch (TopologicalSortException e) {
    Debug.warning (e);
    System.err.println ("TopologicalSortException: Topological Sets:" + Arrays.toString (e.topologicalSets ())); // NOI18N
    System.err.println ("TopologicalSortException: Unsortable Set:" + Arrays.toString (e.unsortableSets ())); // NOI18N
    this.topology = Collections.emptyList ();
    this.dependencyMap = Collections.emptyMap ();
  }
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-bootstrap

/** 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);
  }
}
private void addToJaveleonDisableList(Set<Module> willDisable, Module m) {

代码示例来源:origin: org.netbeans.modules/org-netbeans-core

/** Resort the loader pool according to stated dependencies.
* Attempts to keep a stable order whenever possible, i.e. more-recently-installed
* loaders will tend to stay near the end unless they need to be moved forward.
* Note that dependencies on nonexistent (or unloadable) representation classes are simply
* ignored and have no effect on ordering.
* If there is a cycle (contradictory set of dependencies) in the loader pool,
* its order is not changed.
* In any case, a change event is fired afterwards.
*/
private static synchronized void resort (NbLoaderPool pool) {
  // A partial ordering over loaders based on their Install-* tags:
  Map<DataLoader,List<DataLoader>> deps = new HashMap<DataLoader,List<DataLoader>>();
  add2Deps(deps, installBefores, true);
  add2Deps(deps, installAfters, false);
  if (err.isLoggable(Level.FINE)) {
    err.fine("Before sort: " + loaders);
  }
  
  try {
    loaders = Utilities.topologicalSort(loaders, deps);
    if (err.isLoggable(Level.FINE)) {
      err.fine("After sort: " + loaders);
    }
  } catch (TopologicalSortException ex) {
    err.log(Level.WARNING, null, ex);
    err.warning("Contradictory loader ordering: " + deps); // NOI18N
  }
  update (pool);
}
/**

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide

result = (Set[])Utilities.topologicalSort(sets, edgesBetweenSets).toArray (new Set[0]);
} catch (TopologicalSortException ex) {
  throw new IllegalStateException ("Cannot happen"); // NOI18N

代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide

result = (Set[])Utilities.topologicalSort(sets, edgesBetweenSets).toArray (new Set[0]);
} catch (TopologicalSortException ex) {
  throw new IllegalStateException ("Cannot happen"); // NOI18N

代码示例来源:origin: in.jlibs/org-openide-util

List<Set> listResult = Utilities.topologicalSort(sets, edgesBetweenSets);
  result = listResult.toArray(new Set[0]);
} catch (TopologicalSortException ex) {

代码示例来源:origin: uk.gov.nationalarchives.thirdparty.netbeans/org-openide-util

List<Set> listResult = Utilities.topologicalSort(sets, edgesBetweenSets);
  result = listResult.toArray(new Set[0]);
} catch (TopologicalSortException ex) {

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-ruby-rakeproject

sorted = Utilities.topologicalSort(toSort, dependOnSiblings);
} catch (TopologicalSortException e) {

代码示例来源:origin: org.netbeans.modules/org-netbeans-bootstrap

Map<Module,List<Module>> deps = Util.moduleDependencies(willDisable, modulesByName, getProvidersOf());
try {
  return Utilities.topologicalSort(willDisable, deps);
} catch (TopologicalSortException ex) {

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-vmd-midp

return Utilities.topologicalSort (list, map);
} catch (TopologicalSortException e) {
  Debug.warning ("Topological sort failed", "UnsortableSets", e.unsortableSets ()); // NOI18N

代码示例来源:origin: org.netbeans.modules/org-netbeans-bootstrap

Map<Module,List<Module>> deps = Util.moduleDependencies(willEnable, modulesByName, getProvidersOf());
try {
  List<Module> l = Utilities.topologicalSort(willEnable, deps);
  Collections.reverse(l);
  mdc.registerEnable(modules, l);

代码示例来源:origin: org.netbeans.modules/org-netbeans-bootstrap

List<Module> sortedModules;
try {
  sortedModules = Utilities.topologicalSort(unorderedModules, deps);
} catch (TopologicalSortException ex) {

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide-loaders

return Utilities.topologicalSort(l, constraints);
} catch (TopologicalSortException ex) {
  List corrected = ex.partialSort();

相关文章

微信公众号

最新文章

更多