Browse Source

Add getLabelToStatesMap() to explicit.Model.

This returns a map view of the (optionally stored) label info,
i.e., a map from label name strings to Bitsets of satisfying states.

A default implementation is added using existing methods.
accumulation-v4.7
Dave Parker 6 years ago
parent
commit
612df15a71
  1. 20
      prism/src/explicit/Model.java
  2. 6
      prism/src/explicit/ModelExplicit.java

20
prism/src/explicit/Model.java

@ -32,8 +32,10 @@ import java.util.BitSet;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.PrimitiveIterator;
import java.util.Set;
import java.util.TreeMap;
import java.util.function.IntPredicate;
import common.IteratorTools;
@ -141,9 +143,25 @@ public interface Model
*/
public Set<String> getLabels();
/** Returns true if a label with the given name is attached to this model */
/**
* Returns true if a label with the given name is attached to this model
*/
public boolean hasLabel(String name);
/**
* Get the mapping from labels that are (optionally) stored
* to the sets of states that satisfy them.
*/
default Map<String, BitSet> getLabelToStatesMap()
{
// Default implementation creates a new map on demand
Map<String, BitSet> labels = new TreeMap<String, BitSet>();
for (String name : getLabels()) {
labels.put(name, getLabelStates(name));
}
return labels;
}
/**
* Get the total number of transitions in the model.
*/

6
prism/src/explicit/ModelExplicit.java

@ -346,6 +346,12 @@ public abstract class ModelExplicit implements Model
return labels.keySet();
}
@Override
public Map<String, BitSet> getLabelToStatesMap()
{
return labels;
}
@Override
public void checkForDeadlocks() throws PrismException
{

Loading…
Cancel
Save