comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WQDay.java @ 3468:f37e7e8907cb

merged flys-artifacts/2.8.1
author Thomas Arendsen Hein <thomas@intevation.de>
date Fri, 28 Sep 2012 12:14:39 +0200
parents 5ff481ab24a1
children
comparison
equal deleted inserted replaced
3387:5ffad8bde8ad 3468:f37e7e8907cb
1 package de.intevation.flys.artifacts.model;
2
3 import gnu.trove.TIntArrayList;
4
5 /**
6 * This class represents a pool of data triples that consists of 'W', 'Q' and
7 * 'Day' data.
8 *
9 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
10 */
11 public class WQDay
12 extends WQ
13 {
14 protected TIntArrayList days;
15
16 public WQDay() {
17 super("");
18 days = new TIntArrayList();
19 }
20
21 public WQDay(int capacity) {
22 super(capacity);
23 days = new TIntArrayList(capacity);
24 }
25
26 public WQDay(int [] days, double [] ws, double [] qs) {
27 super(qs, ws, "");
28 this.days = new TIntArrayList(days);
29 }
30
31
32 public void add(int day, double w, double q) {
33 super.add(w, q);
34 days.add(day);
35 }
36
37
38 public boolean isIncreasing() {
39 int lo = getDay(0);
40 int hi = getDay(size()-1);
41
42 return lo < hi;
43 }
44
45
46 public int getDay(int idx) {
47 return days.getQuick(idx);
48 }
49
50 @Override
51 public void removeNaNs() {
52
53 int dest = 0;
54 int N = ws.size();
55
56 for (int i = 0; i < N; ++i) {
57 double wi = ws.getQuick(i);
58 double qi = qs.getQuick(i);
59
60 if (Double.isNaN(wi) || Double.isNaN(qi)) {
61 continue;
62 }
63
64 days.setQuick(dest, days.getQuick(i));
65 ws.setQuick(dest, wi);
66 qs.setQuick(dest, qi);
67 ++dest;
68 }
69
70 if (dest < N) {
71 days.remove(dest, N-dest);
72 ws .remove(dest, N-dest);
73 qs .remove(dest, N-dest);
74 }
75 }
76 }
77 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org