Browse Source

Added compare by variable to the State class

git-svn-id: https://www.prismmodelchecker.org/svn/prism/prism/trunk@7218 bbc10eb1-c90d-0410-af57-cb519fbb1720
master
Mateusz Ujma 13 years ago
parent
commit
831876fc85
  1. 30
      prism/src/parser/State.java

30
prism/src/parser/State.java

@ -162,6 +162,11 @@ public class State implements Comparable<State>
}
public int compareTo(State s)
{
return compareTo(s, 0);
}
public int compareTo(State s, int variableIndex)
{
int i, j, n;
Object svv[], o1, o2;
@ -173,8 +178,31 @@ public class State implements Comparable<State>
n = varValues.length;
if (n != svv.length)
throw new ClassCastException("States are different sizes");
if (variableIndex > n-1)
throw new ClassCastException("Variable index is incorrect");
// Go through array
for (i = 0; i < n; i++) {
for (i = variableIndex; i < n; i++) {
o1 = varValues[i];
o2 = svv[i];
if (o1 instanceof Integer && o2 instanceof Integer) {
j = ((Integer) o1).compareTo((Integer) o2);
if (j != 0)
return j;
else
continue;
} else if (o1 instanceof Boolean && o2 instanceof Boolean) {
j = ((Boolean) o1).compareTo((Boolean) o2);
if (j != 0)
return j;
else
continue;
} else {
throw new ClassCastException("Can't compare " + o1.getClass() + " and " + o2.getClass());
}
}
for (i = 0; i < variableIndex; i++) {
o1 = varValues[i];
o2 = svv[i];
if (o1 instanceof Integer && o2 instanceof Integer) {

Loading…
Cancel
Save