当前位置: 首页>>代码示例>>Java>>正文


Java IntStack.isEmpty方法代码示例

本文整理汇总了Java中com.carrotsearch.hppc.IntStack.isEmpty方法的典型用法代码示例。如果您正苦于以下问题:Java IntStack.isEmpty方法的具体用法?Java IntStack.isEmpty怎么用?Java IntStack.isEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.carrotsearch.hppc.IntStack的用法示例。


在下文中一共展示了IntStack.isEmpty方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: computeInlinkCount

import com.carrotsearch.hppc.IntStack; //导入方法依赖的package包/类
/**
 * Compute in-link count for each state.
 */
private IntIntHashMap computeInlinkCount(final FSA fsa) {
  IntIntHashMap inlinkCount = new IntIntHashMap();
  BitSet visited = new BitSet();
  IntStack nodes = new IntStack();
  nodes.push(fsa.getRootNode());

  while (!nodes.isEmpty()) {
    final int node = nodes.pop();
    if (visited.get(node))
      continue;

    visited.set(node);

    for (int arc = fsa.getFirstArc(node); arc != 0; arc = fsa.getNextArc(arc)) {
      if (!fsa.isArcTerminal(arc)) {
        final int target = fsa.getEndNode(arc);
        inlinkCount.putOrAdd(target, 1, 1);
        if (!visited.get(target))
          nodes.push(target);
      }
    }
  }

  return inlinkCount;
}
 
开发者ID:morfologik,项目名称:morfologik-stemming,代码行数:29,代码来源:CFSA2Serializer.java

示例2: buildPropagationPath

import com.carrotsearch.hppc.IntStack; //导入方法依赖的package包/类
private void buildPropagationPath() {
    byte[] state = new byte[types.length];
    int[] path = new int[types.length];
    int pathSize = 0;
    IntStack stack = new IntStack();

    for (int i = 0; i < graph.size(); ++i) {
        if (graph.incomingEdgesCount(i) == 0 && types[i] != null) {
            stack.push(i);
        }
    }

    while (!stack.isEmpty()) {
        int node = stack.pop();
        if (state[node] == FRESH) {
            state[node] = VISITING;

            stack.push(node);

            for (int successor : graph.outgoingEdges(node)) {
                if (state[successor] == FRESH) {
                    stack.push(successor);
                }
            }

        } else if (state[node] == VISITING) {
            path[pathSize++] = node;
            state[node] = VISITED;
        }
    }

    propagationPath = Arrays.copyOf(path, pathSize);
}
 
开发者ID:konsoletyper,项目名称:teavm,代码行数:34,代码来源:ClassInference.java

示例3: linearize

import com.carrotsearch.hppc.IntStack; //导入方法依赖的package包/类
/**
 * Linearization of states.
 */
private int[] linearize(final FSA fsa) {
  int[] linearized = new int[0];
  int last = 0;

  BitSet visited = new BitSet();
  IntStack nodes = new IntStack();
  nodes.push(fsa.getRootNode());

  while (!nodes.isEmpty()) {
    final int node = nodes.pop();
    if (visited.get(node)) {
      continue;
    }

    if (last >= linearized.length) {
      linearized = Arrays.copyOf(linearized, linearized.length + 100000);
    }

    visited.set(node);
    linearized[last++] = node;

    for (int arc = fsa.getFirstArc(node); arc != 0; arc = fsa.getNextArc(arc)) {
      if (!fsa.isArcTerminal(arc)) {
        int target = fsa.getEndNode(arc);
        if (!visited.get(target))
          nodes.push(target);
      }
    }
  }

  return Arrays.copyOf(linearized, last);
}
 
开发者ID:morfologik,项目名称:morfologik-stemming,代码行数:36,代码来源:FSA5Serializer.java

示例4: linearizeAndCalculateOffsets

import com.carrotsearch.hppc.IntStack; //导入方法依赖的package包/类
/**
 * Linearize all states, putting <code>states</code> in front of the automaton
 * and calculating stable state offsets.
 */
private int linearizeAndCalculateOffsets(FSA fsa, IntArrayList states, IntArrayList linearized,
    IntIntHashMap offsets) throws IOException {
  final BitSet visited = new BitSet();
  final IntStack nodes = new IntStack();
  linearized.clear();

  /*
   * Linearize states with most inlinks first.
   */
  for (int i = 0; i < states.size(); i++) {
    linearizeState(fsa, nodes, linearized, visited, states.get(i));
  }

  /*
   * Linearize the remaining states by chaining them one after another, in depth-order.
   */
  nodes.push(fsa.getRootNode());
  while (!nodes.isEmpty()) {
    final int node = nodes.pop();
    if (visited.get(node))
      continue;

    linearizeState(fsa, nodes, linearized, visited, node);
  }

  /*
   * Calculate new state offsets. This is iterative. We start with 
   * maximum potential offsets and recalculate until converged.
   */
  int MAX_OFFSET = Integer.MAX_VALUE;
  for (IntCursor c : linearized) {
    offsets.put(c.value, MAX_OFFSET);
  }

  int i, j = 0;
  while ((i = emitNodes(fsa, null, linearized)) > 0) {
    j = i;
  }
  return j;
}
 
开发者ID:morfologik,项目名称:morfologik-stemming,代码行数:45,代码来源:CFSA2Serializer.java


注:本文中的com.carrotsearch.hppc.IntStack.isEmpty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。