本文整理汇总了Java中org.apache.lucene.util.ArrayUtil.toIntArray方法的典型用法代码示例。如果您正苦于以下问题:Java ArrayUtil.toIntArray方法的具体用法?Java ArrayUtil.toIntArray怎么用?Java ArrayUtil.toIntArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.lucene.util.ArrayUtil
的用法示例。
在下文中一共展示了ArrayUtil.toIntArray方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toArray
import org.apache.lucene.util.ArrayUtil; //导入方法依赖的package包/类
public static int[] toArray(DocsEnum docsEnum) throws IOException {
List<Integer> docs = new ArrayList<>();
while (docsEnum.nextDoc() != DocIdSetIterator.NO_MORE_DOCS) {
int docID = docsEnum.docID();
docs.add(docID);
}
return ArrayUtil.toIntArray(docs);
}
示例2: getRandomAcceptedString
import org.apache.lucene.util.ArrayUtil; //导入方法依赖的package包/类
public int[] getRandomAcceptedString(Random r) {
final List<Integer> soFar = new ArrayList<>();
int s = 0;
while(true) {
if (a.isAccept(s)) {
if (a.getNumTransitions(s) == 0) {
// stop now
break;
} else {
if (r.nextBoolean()) {
break;
}
}
}
if (a.getNumTransitions(s) == 0) {
throw new RuntimeException("this automaton has dead states");
}
boolean cheat = r.nextBoolean();
final Transition t;
if (cheat) {
// pick a transition that we know is the fastest
// path to an accept state
List<Transition> toAccept = new ArrayList<>();
for(Transition t0 : transitions[s]) {
if (leadsToAccept.containsKey(t0)) {
toAccept.add(t0);
}
}
if (toAccept.size() == 0) {
// this is OK -- it means we jumped into a cycle
t = transitions[s][r.nextInt(transitions[s].length)];
} else {
t = toAccept.get(r.nextInt(toAccept.size()));
}
} else {
t = transitions[s][r.nextInt(transitions[s].length)];
}
soFar.add(getRandomCodePoint(r, t.min, t.max));
s = t.dest;
}
return ArrayUtil.toIntArray(soFar);
}