org.apache.lucene.util.automaton.Operations.topoSortStatesRecurse()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(5.5k)|赞(0)|评价(0)|浏览(143)

本文整理了Java中org.apache.lucene.util.automaton.Operations.topoSortStatesRecurse()方法的一些代码示例,展示了Operations.topoSortStatesRecurse()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Operations.topoSortStatesRecurse()方法的具体详情如下:
包路径:org.apache.lucene.util.automaton.Operations
类名称:Operations
方法名:topoSortStatesRecurse

Operations.topoSortStatesRecurse介绍

暂无

代码示例

代码示例来源:origin: org.apache.lucene/lucene-core

  1. private static int topoSortStatesRecurse(Automaton a, BitSet visited, int[] states, int upto, int state, int level) {
  2. if (level > MAX_RECURSION_LEVEL) {
  3. throw new IllegalArgumentException("input automaton is too large: " + level);
  4. }
  5. Transition t = new Transition();
  6. int count = a.initTransition(state, t);
  7. for (int i=0;i<count;i++) {
  8. a.getNextTransition(t);
  9. if (!visited.get(t.dest)) {
  10. visited.set(t.dest);
  11. upto = topoSortStatesRecurse(a, visited, states, upto, t.dest, level+1);
  12. }
  13. }
  14. states[upto] = state;
  15. upto++;
  16. return upto;
  17. }
  18. }

代码示例来源:origin: org.apache.lucene/lucene-core

  1. /** Returns the topological sort of all states reachable from
  2. * the initial state. Behavior is undefined if this
  3. * automaton has cycles. CPU cost is O(numTransitions),
  4. * and the implementation is recursive so an automaton
  5. * matching long strings may exhaust the java stack. */
  6. public static int[] topoSortStates(Automaton a) {
  7. if (a.getNumStates() == 0) {
  8. return new int[0];
  9. }
  10. int numStates = a.getNumStates();
  11. int[] states = new int[numStates];
  12. final BitSet visited = new BitSet(numStates);
  13. int upto = topoSortStatesRecurse(a, visited, states, 0, 0, 0);
  14. if (upto < states.length) {
  15. // There were dead states
  16. int[] newStates = new int[upto];
  17. System.arraycopy(states, 0, newStates, 0, upto);
  18. states = newStates;
  19. }
  20. // Reverse the order:
  21. for(int i=0;i<states.length/2;i++) {
  22. int s = states[i];
  23. states[i] = states[states.length-1-i];
  24. states[states.length-1-i] = s;
  25. }
  26. return states;
  27. }

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.lucene

  1. private static int topoSortStatesRecurse(Automaton a, BitSet visited, int[] states, int upto, int state, int level) {
  2. if (level > MAX_RECURSION_LEVEL) {
  3. throw new IllegalArgumentException("input automaton is too large: " + level);
  4. }
  5. Transition t = new Transition();
  6. int count = a.initTransition(state, t);
  7. for (int i=0;i<count;i++) {
  8. a.getNextTransition(t);
  9. if (!visited.get(t.dest)) {
  10. visited.set(t.dest);
  11. upto = topoSortStatesRecurse(a, visited, states, upto, t.dest, level+1);
  12. }
  13. }
  14. states[upto] = state;
  15. upto++;
  16. return upto;
  17. }
  18. }

代码示例来源:origin: org.infinispan/infinispan-embedded-query

  1. private static int topoSortStatesRecurse(Automaton a, BitSet visited, int[] states, int upto, int state) {
  2. Transition t = new Transition();
  3. int count = a.initTransition(state, t);
  4. for (int i=0;i<count;i++) {
  5. a.getNextTransition(t);
  6. if (!visited.get(t.dest)) {
  7. visited.set(t.dest);
  8. upto = topoSortStatesRecurse(a, visited, states, upto, t.dest);
  9. }
  10. }
  11. states[upto] = state;
  12. upto++;
  13. return upto;
  14. }
  15. }

代码示例来源:origin: harbby/presto-connectors

  1. /** Returns the topological sort of all states reachable from
  2. * the initial state. Behavior is undefined if this
  3. * automaton has cycles. CPU cost is O(numTransitions),
  4. * and the implementation is recursive so an automaton
  5. * matching long strings may exhaust the java stack. */
  6. public static int[] topoSortStates(Automaton a) {
  7. if (a.getNumStates() == 0) {
  8. return new int[0];
  9. }
  10. int numStates = a.getNumStates();
  11. int[] states = new int[numStates];
  12. final BitSet visited = new BitSet(numStates);
  13. int upto = topoSortStatesRecurse(a, visited, states, 0, 0);
  14. if (upto < states.length) {
  15. // There were dead states
  16. int[] newStates = new int[upto];
  17. System.arraycopy(states, 0, newStates, 0, upto);
  18. states = newStates;
  19. }
  20. // Reverse the order:
  21. for(int i=0;i<states.length/2;i++) {
  22. int s = states[i];
  23. states[i] = states[states.length-1-i];
  24. states[states.length-1-i] = s;
  25. }
  26. return states;
  27. }

代码示例来源:origin: harbby/presto-connectors

  1. private static int topoSortStatesRecurse(Automaton a, BitSet visited, int[] states, int upto, int state) {
  2. Transition t = new Transition();
  3. int count = a.initTransition(state, t);
  4. for (int i=0;i<count;i++) {
  5. a.getNextTransition(t);
  6. if (!visited.get(t.dest)) {
  7. visited.set(t.dest);
  8. upto = topoSortStatesRecurse(a, visited, states, upto, t.dest);
  9. }
  10. }
  11. states[upto] = state;
  12. upto++;
  13. return upto;
  14. }
  15. }

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.lucene

  1. /** Returns the topological sort of all states reachable from
  2. * the initial state. Behavior is undefined if this
  3. * automaton has cycles. CPU cost is O(numTransitions),
  4. * and the implementation is recursive so an automaton
  5. * matching long strings may exhaust the java stack. */
  6. public static int[] topoSortStates(Automaton a) {
  7. if (a.getNumStates() == 0) {
  8. return new int[0];
  9. }
  10. int numStates = a.getNumStates();
  11. int[] states = new int[numStates];
  12. final BitSet visited = new BitSet(numStates);
  13. int upto = topoSortStatesRecurse(a, visited, states, 0, 0, 0);
  14. if (upto < states.length) {
  15. // There were dead states
  16. int[] newStates = new int[upto];
  17. System.arraycopy(states, 0, newStates, 0, upto);
  18. states = newStates;
  19. }
  20. // Reverse the order:
  21. for(int i=0;i<states.length/2;i++) {
  22. int s = states[i];
  23. states[i] = states[states.length-1-i];
  24. states[states.length-1-i] = s;
  25. }
  26. return states;
  27. }

代码示例来源:origin: org.infinispan/infinispan-embedded-query

  1. /** Returns the topological sort of all states reachable from
  2. * the initial state. Behavior is undefined if this
  3. * automaton has cycles. CPU cost is O(numTransitions),
  4. * and the implementation is recursive so an automaton
  5. * matching long strings may exhaust the java stack. */
  6. public static int[] topoSortStates(Automaton a) {
  7. if (a.getNumStates() == 0) {
  8. return new int[0];
  9. }
  10. int numStates = a.getNumStates();
  11. int[] states = new int[numStates];
  12. final BitSet visited = new BitSet(numStates);
  13. int upto = topoSortStatesRecurse(a, visited, states, 0, 0);
  14. if (upto < states.length) {
  15. // There were dead states
  16. int[] newStates = new int[upto];
  17. System.arraycopy(states, 0, newStates, 0, upto);
  18. states = newStates;
  19. }
  20. // Reverse the order:
  21. for(int i=0;i<states.length/2;i++) {
  22. int s = states[i];
  23. states[i] = states[states.length-1-i];
  24. states[states.length-1-i] = s;
  25. }
  26. return states;
  27. }

相关文章