Java 类it.unimi.dsi.fastutil.ints.IntStack 实例源码

项目:scala-playground    文件:DirectedCycle.java   
public static void main(String[] args) {
  Path path = Paths.get("/Users/apple/depot/scala-playground/src/main/java/dsAlgo/graph/directedGraphWithCycle.txt");
  DirectedGraph graph = DirectedGraph.loadFromFile(path);
  DirectedCycle cycle = new DirectedCycle(graph);
  if (cycle.hasCycle()) {
    StringBuilder sb = new StringBuilder();
    IntStack stack = cycle.cycle();
    while (!stack.isEmpty()) {
      sb.append(stack.popInt());
      if (!stack.isEmpty()) sb.append(" -> ");
    }
    System.out.println(sb.toString());
  }
}
项目:scala-playground    文件:BFS.java   
public IntStack pathTo(int w) {
  if (isConnectedTo(w)) {
    IntStack result = new IntArrayList();

    for (int r = w; r != sourceVertex; r = edgeTo[r])
      result.push(r);

    result.push(sourceVertex);

    return result;
  } else {
    return new IntArrayList(0);
  }
}
项目:scala-playground    文件:DFS.java   
public IntStack pathTo(int w) {
  if (isConnectedTo(w)) {
    IntStack result = new IntArrayList();

    for (int r = w; r != sourceVertex; r = edgeTo[r])
      result.push(r);

    result.push(sourceVertex);

    return result;
  } else {
    return new IntArrayList(0);
  }
}
项目:scala-playground    文件:DirectedCycle.java   
public IntStack cycle() { return cycle; }