1 2 21 package gov.nasa.ltl.trans; 23 24 import java.util.*; 25 26 27 30 class State implements Comparable { 31 private int representativeId = -1; 32 private LinkedList transitions; 33 private BitSet accepting; 34 private boolean safety_acceptance; 35 36 public State (BitSet acc) { 37 transitions = new LinkedList(); 38 accepting = acc; 39 safety_acceptance = false; 40 } 41 42 public State (BitSet acc, int equivId) { 43 transitions = new LinkedList(); 44 accepting = acc; 45 safety_acceptance = false; 46 representativeId = equivId; 47 } 48 49 public State () { 50 transitions = new LinkedList(); 51 accepting = null; 52 safety_acceptance = false; 53 } 54 55 public State (int equivId) { 56 transitions = new LinkedList(); 57 accepting = null; 58 safety_acceptance = false; 59 representativeId = equivId; 60 } 61 62 67 public void FSPoutput () { 68 ListIterator iter = transitions.listIterator(0); 69 Transition nextTrans; 70 boolean first_trans = true; 71 72 while (iter.hasNext()) { 73 nextTrans = (Transition) iter.next(); 74 75 if (first_trans) { 76 System.out.print("("); 77 first_trans = false; 78 } else { 79 System.out.print("|"); 80 } 81 82 nextTrans.FSPoutput(); 83 } 84 } 85 86 public void SMoutput (gov.nasa.ltl.graph.Node[] nodes, 87 gov.nasa.ltl.graph.Node node) { 88 ListIterator iter = transitions.listIterator(0); 89 Transition nextTrans; 90 boolean first_trans = true; 91 92 while (iter.hasNext()) { 93 nextTrans = (Transition) iter.next(); 94 nextTrans.SMoutput(nodes, node); 95 } 96 } 97 98 public boolean accepts (int i) { 99 return (!(accepting.get(i))); 100 101 } 103 104 public void add (Transition trans) { 107 transitions.add(trans); 108 } 109 110 public int compareTo (Object f) { 111 if (this == f) { 112 return 0; 113 } else { 114 return 1; 115 } 116 } 117 118 public int get_representativeId () { 119 return representativeId; 120 } 121 122 public boolean is_safe () { 123 return safety_acceptance; 124 } 125 126 public void set_representativeId (int id) { 127 representativeId = id; 128 } 129 130 public void step (Hashtable ProgramState, TreeSet newStates, 131 State[] automaton) { 132 ListIterator iter = transitions.listIterator(0); 133 Transition nextTrans; 134 135 while (iter.hasNext()) { 136 nextTrans = (Transition) iter.next(); 137 138 if (nextTrans.enabled(ProgramState)) { 139 newStates.add(automaton[nextTrans.goesTo()]); 140 } 141 } 142 } 143 144 public void update_acc (BitSet acc) { 145 accepting = acc; 146 } 147 148 public void update_acc (BitSet acc, int equivId) { 149 accepting = acc; 150 representativeId = equivId; 151 } 152 153 public void update_safety_acc (boolean val) { 154 safety_acceptance = val; 155 } 156 } | Popular Tags |