Browse Source

Distribution: provide constructor from Iterator over the transitions (Entry<Integer, Double>)

git-svn-id: https://www.prismmodelchecker.org/svn/prism/prism/trunk@12117 bbc10eb1-c90d-0410-af57-cb519fbb1720
master
Joachim Klein 9 years ago
parent
commit
798dd1e859
  1. 15
      prism/src/explicit/Distribution.java

15
prism/src/explicit/Distribution.java

@ -55,12 +55,19 @@ public class Distribution implements Iterable<Entry<Integer, Double>>
* Copy constructor.
*/
public Distribution(Distribution distr)
{
this(distr.iterator());
}
/**
* Construct a distribution from an iterator over transitions.
*/
public Distribution(Iterator<Entry<Integer, Double>> transitions)
{
this();
Iterator<Entry<Integer, Double>> i = distr.iterator();
while (i.hasNext()) {
Map.Entry<Integer, Double> e = i.next();
add(e.getKey(), e.getValue());
while (transitions.hasNext()) {
final Entry<Integer, Double> trans = transitions.next();
add(trans.getKey(), trans.getValue());
}
}

Loading…
Cancel
Save