本文整理汇总了Java中com.carrotsearch.hppc.IntStack.push方法的典型用法代码示例。如果您正苦于以下问题:Java IntStack.push方法的具体用法?Java IntStack.push怎么用?Java IntStack.push使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.carrotsearch.hppc.IntStack
的用法示例。
在下文中一共展示了IntStack.push方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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);
}
示例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);
}
示例4: linearizeState
import com.carrotsearch.hppc.IntStack; //导入方法依赖的package包/类
/**
* Add a state to linearized list.
*/
private void linearizeState(final FSA fsa, IntStack nodes, IntArrayList linearized, BitSet visited, int node) {
linearized.add(node);
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);
if (!visited.get(target))
nodes.push(target);
}
}
}
示例5: 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;
}