sascha@4091: package de.intevation.aft; sascha@4091: sascha@4091: import java.util.Comparator; sascha@4091: sascha@4091: public class WQ sascha@4091: { sascha@4091: public static final double EPSILON = 1e-4; sascha@4091: sascha@4091: public static final Comparator WQ_EPS_CMP = new Comparator() { sascha@4091: @Override sascha@4091: public int compare(WQ a, WQ b) { sascha@4091: int cmp = compareEpsilon(a.w, b.w); sascha@4091: if (cmp != 0) return cmp; sascha@4091: return compareEpsilon(a.q, b.q); sascha@4091: } sascha@4091: }; sascha@4091: sascha@4091: protected int id; sascha@4091: sascha@4091: protected double w; sascha@4091: protected double q; sascha@4091: sascha@4091: public WQ() { sascha@4091: } sascha@4091: sascha@4091: public WQ(double w, double q) { sascha@4091: this.w = w; sascha@4091: this.q = q; sascha@4091: } sascha@4091: sascha@4091: public WQ(int id, double w, double q) { sascha@4091: this.id = id; sascha@4091: this.w = w; sascha@4091: this.q = q; sascha@4091: } sascha@4091: sascha@4091: public static final int compareEpsilon(double a, double b) { sascha@4091: double diff = a - b; sascha@4091: if (diff < -EPSILON) return -1; sascha@4091: return diff > EPSILON ? +1 : 0; sascha@4091: } sascha@4091: sascha@4091: public int getId() { sascha@4091: return id; sascha@4091: } sascha@4091: sascha@4091: public void setId(int id) { sascha@4091: this.id = id; sascha@4091: } sascha@4091: sascha@4091: public double getW() { sascha@4091: return w; sascha@4091: } sascha@4091: sascha@4091: public void setW(double w) { sascha@4091: this.w = w; sascha@4091: } sascha@4091: sascha@4091: public double getQ() { sascha@4091: return q; sascha@4091: } sascha@4091: sascha@4091: public void setQ(double q) { sascha@4091: this.q = q; sascha@4091: } sascha@4091: } sascha@4091: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :