teichmann@4817: package de.intevation.flys.artifacts.model;
teichmann@4817: 
teichmann@4817: import gnu.trove.TDoubleArrayList;
teichmann@4817: 
teichmann@4821: import de.intevation.flys.utils.DoubleUtil;
teichmann@4821: 
teichmann@4817: public class QKmsImpl
teichmann@4817: extends      NamedObjectImpl
teichmann@4817: implements   QKms
teichmann@4817: {
teichmann@4817:     protected TDoubleArrayList kms;
teichmann@4817:     protected TDoubleArrayList qs;
teichmann@4817: 
teichmann@4817:     public QKmsImpl() {
teichmann@4817:         super("");
teichmann@4817:         kms = new TDoubleArrayList();
teichmann@4817:         qs  = new TDoubleArrayList();
teichmann@4817:     }
teichmann@4817: 
teichmann@4817:     public QKmsImpl(String name) {
teichmann@4817:         super(name);
teichmann@4817:         kms = new TDoubleArrayList();
teichmann@4817:         qs  = new TDoubleArrayList();
teichmann@4817:     }
teichmann@4817: 
teichmann@4817: 
teichmann@4817:     public QKmsImpl(int capacity) {
teichmann@4817:         super("");
teichmann@4817:         kms = new TDoubleArrayList(capacity);
teichmann@4817:         qs  = new TDoubleArrayList(capacity);
teichmann@4817:     }
teichmann@4817: 
teichmann@4817: 
teichmann@4817:     public QKmsImpl(TDoubleArrayList kms, TDoubleArrayList qs) {
teichmann@4817:         this(kms, qs, "");
teichmann@4817:     }
teichmann@4817: 
teichmann@4817:     public QKmsImpl(
teichmann@4817:         TDoubleArrayList kms,
teichmann@4817:         TDoubleArrayList qs,
teichmann@4817:         String           name
teichmann@4817:     ) {
teichmann@4817:         super(name);
teichmann@4817:         this.kms = kms;
teichmann@4817:         this.qs  = qs;
teichmann@4817:     }
teichmann@4817: 
teichmann@4817:     public void add(double km, double q) {
teichmann@4817:         kms.add(km);
teichmann@4817:         qs .add(q);
teichmann@4817:     }
teichmann@4817: 
teichmann@4817:     @Override
teichmann@4817:     public double getQ(int index) {
teichmann@4817:         return qs.getQuick(index);
teichmann@4817:     }
teichmann@4817: 
teichmann@4817: 
teichmann@4817:     @Override
teichmann@4817:     public double getKm(int index) {
teichmann@4817:         return kms.getQuick(index);
teichmann@4817:     }
teichmann@4817: 
teichmann@4817:     @Override
teichmann@4817:     public int size() {
teichmann@4817:         return kms.size();
teichmann@4817:     }
teichmann@4817: 
teichmann@4817:     @Override
teichmann@4817:     public TDoubleArrayList allKms() {
teichmann@4817:         return kms;
teichmann@4817:     }
teichmann@4817: 
teichmann@4817:     @Override
teichmann@4817:     public TDoubleArrayList allQs() {
teichmann@4817:         return qs;
teichmann@4817:     }
teichmann@4821: 
teichmann@4821:     public void removeNaNs() {
teichmann@4821:         DoubleUtil.removeNaNs(new TDoubleArrayList [] { kms, qs });
teichmann@4821:     }
teichmann@4817: }