altoslib: Add initial time series functions
[fw/altos] / altoslib / AltosTimeSeries.java
1 /*
2  * Copyright © 2017 Keith Packard <keithp@keithp.com>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * General Public License for more details.
13  */
14
15 package org.altusmetrum.altoslib_11;
16
17 import java.util.*;
18
19 public class AltosTimeSeries implements Iterable<AltosTimeValue> {
20         public String           label;
21         public AltosUnits       units;
22         List<AltosTimeValue>    values;
23
24         public void add(double x, double y) {
25                 values.add(new AltosTimeValue(x, y));
26         }
27
28         public Iterator<AltosTimeValue> iterator() {
29                 return values.iterator();
30         }
31
32         public AltosTimeSeries(String label, AltosUnits units) {
33                 this.label = label;
34                 this.units = units;
35                 this.values = new ArrayList<AltosTimeValue>();
36         }
37 }