本文整理了Java中org.apache.lucene.util.automaton.Operations.topoSortStatesRecurse()
方法的一些代码示例,展示了Operations.topoSortStatesRecurse()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Operations.topoSortStatesRecurse()
方法的具体详情如下:
包路径:org.apache.lucene.util.automaton.Operations
类名称:Operations
方法名:topoSortStatesRecurse
暂无
代码示例来源:origin: org.apache.lucene/lucene-core
private static int topoSortStatesRecurse(Automaton a, BitSet visited, int[] states, int upto, int state, int level) {
if (level > MAX_RECURSION_LEVEL) {
throw new IllegalArgumentException("input automaton is too large: " + level);
}
Transition t = new Transition();
int count = a.initTransition(state, t);
for (int i=0;i<count;i++) {
a.getNextTransition(t);
if (!visited.get(t.dest)) {
visited.set(t.dest);
upto = topoSortStatesRecurse(a, visited, states, upto, t.dest, level+1);
}
}
states[upto] = state;
upto++;
return upto;
}
}
代码示例来源:origin: org.apache.lucene/lucene-core
/** Returns the topological sort of all states reachable from
* the initial state. Behavior is undefined if this
* automaton has cycles. CPU cost is O(numTransitions),
* and the implementation is recursive so an automaton
* matching long strings may exhaust the java stack. */
public static int[] topoSortStates(Automaton a) {
if (a.getNumStates() == 0) {
return new int[0];
}
int numStates = a.getNumStates();
int[] states = new int[numStates];
final BitSet visited = new BitSet(numStates);
int upto = topoSortStatesRecurse(a, visited, states, 0, 0, 0);
if (upto < states.length) {
// There were dead states
int[] newStates = new int[upto];
System.arraycopy(states, 0, newStates, 0, upto);
states = newStates;
}
// Reverse the order:
for(int i=0;i<states.length/2;i++) {
int s = states[i];
states[i] = states[states.length-1-i];
states[states.length-1-i] = s;
}
return states;
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.lucene
private static int topoSortStatesRecurse(Automaton a, BitSet visited, int[] states, int upto, int state, int level) {
if (level > MAX_RECURSION_LEVEL) {
throw new IllegalArgumentException("input automaton is too large: " + level);
}
Transition t = new Transition();
int count = a.initTransition(state, t);
for (int i=0;i<count;i++) {
a.getNextTransition(t);
if (!visited.get(t.dest)) {
visited.set(t.dest);
upto = topoSortStatesRecurse(a, visited, states, upto, t.dest, level+1);
}
}
states[upto] = state;
upto++;
return upto;
}
}
代码示例来源:origin: org.infinispan/infinispan-embedded-query
private static int topoSortStatesRecurse(Automaton a, BitSet visited, int[] states, int upto, int state) {
Transition t = new Transition();
int count = a.initTransition(state, t);
for (int i=0;i<count;i++) {
a.getNextTransition(t);
if (!visited.get(t.dest)) {
visited.set(t.dest);
upto = topoSortStatesRecurse(a, visited, states, upto, t.dest);
}
}
states[upto] = state;
upto++;
return upto;
}
}
代码示例来源:origin: harbby/presto-connectors
/** Returns the topological sort of all states reachable from
* the initial state. Behavior is undefined if this
* automaton has cycles. CPU cost is O(numTransitions),
* and the implementation is recursive so an automaton
* matching long strings may exhaust the java stack. */
public static int[] topoSortStates(Automaton a) {
if (a.getNumStates() == 0) {
return new int[0];
}
int numStates = a.getNumStates();
int[] states = new int[numStates];
final BitSet visited = new BitSet(numStates);
int upto = topoSortStatesRecurse(a, visited, states, 0, 0);
if (upto < states.length) {
// There were dead states
int[] newStates = new int[upto];
System.arraycopy(states, 0, newStates, 0, upto);
states = newStates;
}
// Reverse the order:
for(int i=0;i<states.length/2;i++) {
int s = states[i];
states[i] = states[states.length-1-i];
states[states.length-1-i] = s;
}
return states;
}
代码示例来源:origin: harbby/presto-connectors
private static int topoSortStatesRecurse(Automaton a, BitSet visited, int[] states, int upto, int state) {
Transition t = new Transition();
int count = a.initTransition(state, t);
for (int i=0;i<count;i++) {
a.getNextTransition(t);
if (!visited.get(t.dest)) {
visited.set(t.dest);
upto = topoSortStatesRecurse(a, visited, states, upto, t.dest);
}
}
states[upto] = state;
upto++;
return upto;
}
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.lucene
/** Returns the topological sort of all states reachable from
* the initial state. Behavior is undefined if this
* automaton has cycles. CPU cost is O(numTransitions),
* and the implementation is recursive so an automaton
* matching long strings may exhaust the java stack. */
public static int[] topoSortStates(Automaton a) {
if (a.getNumStates() == 0) {
return new int[0];
}
int numStates = a.getNumStates();
int[] states = new int[numStates];
final BitSet visited = new BitSet(numStates);
int upto = topoSortStatesRecurse(a, visited, states, 0, 0, 0);
if (upto < states.length) {
// There were dead states
int[] newStates = new int[upto];
System.arraycopy(states, 0, newStates, 0, upto);
states = newStates;
}
// Reverse the order:
for(int i=0;i<states.length/2;i++) {
int s = states[i];
states[i] = states[states.length-1-i];
states[states.length-1-i] = s;
}
return states;
}
代码示例来源:origin: org.infinispan/infinispan-embedded-query
/** Returns the topological sort of all states reachable from
* the initial state. Behavior is undefined if this
* automaton has cycles. CPU cost is O(numTransitions),
* and the implementation is recursive so an automaton
* matching long strings may exhaust the java stack. */
public static int[] topoSortStates(Automaton a) {
if (a.getNumStates() == 0) {
return new int[0];
}
int numStates = a.getNumStates();
int[] states = new int[numStates];
final BitSet visited = new BitSet(numStates);
int upto = topoSortStatesRecurse(a, visited, states, 0, 0);
if (upto < states.length) {
// There were dead states
int[] newStates = new int[upto];
System.arraycopy(states, 0, newStates, 0, upto);
states = newStates;
}
// Reverse the order:
for(int i=0;i<states.length/2;i++) {
int s = states[i];
states[i] = states[states.length-1-i];
states[states.length-1-i] = s;
}
return states;
}
内容来源于网络,如有侵权,请联系作者删除!