comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WQDay.java @ 686:3dc61e00385e facets-slt

Merged with trunk and introduced hashing of computed values. flys-artifacts/branches/facets-slt@2126 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 15 Jun 2011 15:28:54 +0000
parents 478940d06876
children eab5e5089d77
comparison
equal deleted inserted replaced
667:434146596838 686:3dc61e00385e
32 days = new TIntArrayList(capacity); 32 days = new TIntArrayList(capacity);
33 ws = new TDoubleArrayList(capacity); 33 ws = new TDoubleArrayList(capacity);
34 qs = new TDoubleArrayList(capacity); 34 qs = new TDoubleArrayList(capacity);
35 } 35 }
36 36
37 public WQDay(int [] days, double [] ws, double [] qs) {
38 this.days = new TIntArrayList(days);
39 this.ws = new TDoubleArrayList(ws);
40 this.qs = new TDoubleArrayList(qs);
41 }
42
37 43
38 public void add(int day, double w, double q) { 44 public void add(int day, double w, double q) {
39 days.add(day); 45 days.add(day);
40 ws.add(w); 46 ws.add(w);
41 qs.add(q); 47 qs.add(q);
46 return days.size(); 52 return days.size();
47 } 53 }
48 54
49 55
50 public int getDay(int idx) { 56 public int getDay(int idx) {
51 return days.get(idx); 57 return days.getQuick(idx);
52 } 58 }
53 59
54 60
55 public double getW(int idx) { 61 public double getW(int idx) {
56 return ws.get(idx); 62 return ws.getQuick(idx);
57 } 63 }
58 64
59 65
60 public double getQ(int idx) { 66 public double getQ(int idx) {
61 return qs.get(idx); 67 return qs.getQuick(idx);
68 }
69
70 public void removeNaNs() {
71
72 int dest = 0;
73 int N = ws.size();
74
75 for (int i = 0; i < N; ++i) {
76 double w = ws.getQuick(i);
77 double q = qs.getQuick(i);
78
79 if (Double.isNaN(w) || Double.isNaN(q)) {
80 continue;
81 }
82
83 days.setQuick(dest, days.getQuick(i));
84 ws.setQuick(dest, w);
85 qs.setQuick(dest, q);
86 ++dest;
87 }
88
89 if (dest < N) {
90 days.remove(dest, N-dest);
91 ws .remove(dest, N-dest);
92 qs .remove(dest, N-dest);
93 }
62 } 94 }
63 } 95 }
64 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : 96 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org