1 | package de.uka.ipd.sdq.statistics; |
2 | |
3 | import java.util.ArrayList; |
4 | import java.util.List; |
5 | |
6 | /** |
7 | * Implements some recurring tasks arising when implementing the interface |
8 | * {@link IBatchAlgorithm}. |
9 | * |
10 | * @author Philipp Merkle |
11 | * |
12 | */ |
13 | public abstract class ABatchAlgorithm implements IBatchAlgorithm { |
14 | |
15 | protected List<Batch> batches = new ArrayList<Batch>(); |
16 | |
17 | private boolean valid = false; |
18 | |
19 | @Override |
20 | public void offerSamples(List<Double> values) { |
21 | for (Double v : values) { |
22 | offerSample(v); |
23 | } |
24 | } |
25 | |
26 | @Override |
27 | public void offerSamples(double[] values) { |
28 | for (double v : values) { |
29 | offerSample(v); |
30 | } |
31 | } |
32 | |
33 | @Override |
34 | public List<Double> getBatchMeans() { |
35 | List<Double> means = new ArrayList<Double>(); |
36 | for (Batch b : batches) { |
37 | means.add(b.getMean()); |
38 | } |
39 | return means; |
40 | } |
41 | |
42 | @Override |
43 | public boolean hasValidBatches() { |
44 | return valid; |
45 | } |
46 | |
47 | protected void setValid(boolean valid) { |
48 | this.valid = valid; |
49 | } |
50 | |
51 | } |