本文整理汇总了Java中org.apache.lucene.util.automaton.Transition.getMax方法的典型用法代码示例。如果您正苦于以下问题:Java Transition.getMax方法的具体用法?Java Transition.getMax怎么用?Java Transition.getMax使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.lucene.util.automaton.Transition
的用法示例。
在下文中一共展示了Transition.getMax方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: nextString
import org.apache.lucene.util.automaton.Transition; //导入方法依赖的package包/类
/**
* Returns the next String in lexicographic order that will not put
* the machine into a reject state.
*
* This method traverses the DFA from the given position in the String,
* starting at the given state.
*
* If this cannot satisfy the machine, returns false. This method will
* walk the minimal path, in lexicographic order, as long as possible.
*
* If this method returns false, then there might still be more solutions,
* it is necessary to backtrack to find out.
*
* @param state current non-reject state
* @param position useful portion of the string
* @return true if more possible solutions exist for the DFA from this
* position
*/
private boolean nextString(int state, int position) {
/*
* the next lexicographic character must be greater than the existing
* character, if it exists.
*/
int c = 0;
if (position < seekBytesRef.length) {
c = seekBytesRef.bytes[position] & 0xff;
// if the next byte is 0xff and is not part of the useful portion,
// then by definition it puts us in a reject state, and therefore this
// path is dead. there cannot be any higher transitions. backtrack.
if (c++ == 0xff)
return false;
}
seekBytesRef.length = position;
visited[state] = curGen;
Transition transitions[] = allTransitions[state];
// find the minimal path (lexicographic order) that is >= c
for (int i = 0; i < transitions.length; i++) {
Transition transition = transitions[i];
if (transition.getMax() >= c) {
int nextChar = Math.max(c, transition.getMin());
// append either the next sequential char, or the minimum transition
seekBytesRef.grow(seekBytesRef.length + 1);
seekBytesRef.length++;
seekBytesRef.bytes[seekBytesRef.length - 1] = (byte) nextChar;
state = transition.getDest().getNumber();
/*
* as long as is possible, continue down the minimal path in
* lexicographic order. if a loop or accept state is encountered, stop.
*/
while (visited[state] != curGen && !runAutomaton.isAccept(state)) {
visited[state] = curGen;
/*
* Note: we work with a DFA with no transitions to dead states.
* so the below is ok, if it is not an accept state,
* then there MUST be at least one transition.
*/
transition = allTransitions[state][0];
state = transition.getDest().getNumber();
// append the minimum transition
seekBytesRef.grow(seekBytesRef.length + 1);
seekBytesRef.length++;
seekBytesRef.bytes[seekBytesRef.length - 1] = (byte) transition.getMin();
// we found a loop, record it for faster enumeration
if (!finite && !linear && visited[state] == curGen) {
setLinear(seekBytesRef.length-1);
}
}
return true;
}
}
return false;
}