@Test public void testDrop() { boolean end = false; TsData s = X.clone(); while (!s.isEmpty()) { testIterators(s); if (end) { end = false; s = s.drop(0, 1); } else { end = true; s = s.drop(1, 0); } } }
public TsData drop(final int nfirst, final int nlast) { TsPeriod s = getStart(); s.move(nfirst); int n = vals.length - nfirst - nlast; if (n < 0) { n = 0; } TsData nts = new TsData(s, n); if (n == 0) { return nts; } int nc = n; int s0, t0; if (nfirst < 0) { nc += nfirst; t0 = -nfirst; s0 = 0; Arrays.fill(nts.vals, 0, -nfirst, Double.NaN); } else { s0 = nfirst; t0 = 0; } if (nlast < 0) { nc += nlast; Arrays.fill(nts.vals, nts.vals.length + nlast, nts.vals.length, Double.NaN); } if (nc > 0) { System.arraycopy(vals, s0, nts.vals, t0, nc); } return nts; }
TsData implements Cloneable, Iterable<TsObservation>, IReadDataBlock { public TsData drop(final int nfirst, final int nlast) { TsPeriod s = getStart(); s.move(nfirst); int n = vals.length - nfirst - nlast; if (n < 0) { n = 0; } TsData nts = new TsData(s, n); if (n == 0) { return nts; } int nc = n; int s0, t0; if (nfirst < 0) { nc += nfirst; t0 = -nfirst; s0 = 0; Arrays.fill(nts.vals, 0, -nfirst, Double.NaN); } else { s0 = nfirst; t0 = 0; } if (nlast < 0) { nc += nlast; Arrays.fill(nts.vals, nts.vals.length + nlast, nts.vals.length, Double.NaN); } if (nc > 0) { System.arraycopy(vals, s0, nts.vals, t0, nc); } return nts; } }
TsData implements Cloneable, Iterable<TsObservation>, IReadDataBlock { public TsData drop(final int nfirst, final int nlast) { TsPeriod s = getStart(); s.move(nfirst); int n = vals.length - nfirst - nlast; if (n < 0) { n = 0; } TsData nts = new TsData(s, n); if (n == 0) { return nts; } int nc = n; int s0, t0; if (nfirst < 0) { nc += nfirst; t0 = -nfirst; s0 = 0; Arrays.fill(nts.vals, 0, -nfirst, Double.NaN); } else { s0 = nfirst; t0 = 0; } if (nlast < 0) { nc += nlast; Arrays.fill(nts.vals, nts.vals.length + nlast, nts.vals.length, Double.NaN); } if (nc > 0) { System.arraycopy(vals, s0, nts.vals, t0, nc); } return nts; } TsData(final TsDomain dom);  TsData(final TsDomain dom, double val);   TsData(final TsFrequency freq, final int beg, final int count);  TsData(final TsFrequency freq, final int firstyear,
            final int firstperiod, final double[] data, boolean copydata);  TsData(final TsFrequency freq, final int firstyear,
            final int firstperiod, final int count);  TsData(final TsPeriod start, final double[] data, boolean copydata);  TsData(final TsPeriod start, final int count);  TsData(final TsPeriod start, final IReadDataBlock vals); }
TsData implements Cloneable, Iterable<TsObservation>, IReadDataBlock { public TsData drop(final int nfirst, final int nlast) { TsPeriod s = getStart(); s.move(nfirst); int n = vals.length - nfirst - nlast; if (n < 0) { n = 0; } TsData nts = new TsData(s, n); if (n == 0) { return nts; } int nc = n; int s0, t0; if (nfirst < 0) { nc += nfirst; t0 = -nfirst; s0 = 0; Arrays.fill(nts.vals, 0, -nfirst, Double.NaN); } else { s0 = nfirst; t0 = 0; } if (nlast < 0) { nc += nlast; Arrays.fill(nts.vals, nts.vals.length + nlast, nts.vals.length, Double.NaN); } if (nc > 0) { System.arraycopy(vals, s0, nts.vals, t0, nc); } return nts; } TsData(final TsDomain dom);  TsData(final TsDomain dom, double val);   TsData(final TsFrequency freq, final int beg, final int count);  TsData(final TsFrequency freq, final int firstyear,
            final int firstperiod, final double[] data, boolean copydata);  TsData(final TsFrequency freq, final int firstyear,
            final int firstperiod, final int count);  TsData(final TsPeriod start, final double[] data, boolean copydata);  TsData(final TsPeriod start, final int count);  TsData(final TsPeriod start, final IReadDataBlock vals); static TsData add(final double d, final TsData ts); static TsData add(final TsData tsl, final TsData tsr); static TsData divide(final double d, final TsData ts); static TsData divide(final TsData tsl, final TsData tsr); static TsData multiply(final double d, final TsData ts); static TsData multiply(final TsData tsl, final TsData tsr); static TsData subtract(double d, final TsData ts); static TsData subtract(final TsData tsl, final TsData tsr); static TsData random(TsFrequency freq); static TsData random(TsFrequency freq, int seed); void randomAirline(); double distance(TsData s); @Override void copyTo(double[] buffer, int start); @Override IReadDataBlock rextract(int start, int length); TsData abs(); TsData changeFrequency(final TsFrequency newfreq,
            final TsAggregationType conversion, final boolean complete); TsData chs(); TsData cleanExtremities(); @Override TsData clone(); TsData delta(final int lag); TsData delta(final int lag, final int power); TsData div(final double d); TsData div(final TsData ts); TsData drop(final int nfirst, final int nlast); TsData fullYears(); TsData exp(); TsData round(int ndec); TsData extend(final int nbefore, final int nafter); TsData extendTo(final Day lastday); TsData fittoDomain(final TsDomain dom); boolean isMissing(final int idx); void setMissing(final int idx); @Override double get(final int idx); @NewObject TsDomain getDomain(); @Deprecated Values getValues(); @NewObject TsPeriod getEnd(); TsFrequency getFrequency(); @NewObject TsPeriod getLastPeriod(); @Override int getLength(); int getObsCount(); int getMissingValuesCount(); boolean hasMissingValues(); @NewObject TsPeriod getStart(); TsData index(final TsPeriod refperiod, final double refvalue); TsData inv(); boolean isEmpty(); @Override Iterator<TsObservation> iterator(); Stream<TsObservation> stream(); TsData lag(int nperiods); TsData lead(final int nperiods); TsData log(); TsData log(final double b); TsData sqrt(); TsData minus(final double d); TsData minus(final TsData ts); TsData movingAverage(final double[] weights, final boolean bcentred,
            final boolean bnormalized); TsData movingMedian(final int nperiods, final boolean bcentred); TsData pctVariation(final int lag); TsData plus(final double d); TsData plus(final TsData ts); TsData pow(final double e); TsData select(final TsPeriodSelector ps); void set(final int idx, final double value); TsData times(final double d); TsData times(final TsData ts); TsData update(final TsData ts); static TsData concatenate(TsData l, TsData r); void removeMean(); void normalize(); double get(TsPeriod period); void set(TsPeriod period, double value); @Unsafe double[] internalStorage(); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); boolean equals(TsData other); @Override double computeRecursively(final double initial, DoubleBinaryOperator fn); void apply(DoubleUnaryOperator fn); void applyIf(DoublePredicate pred, DoubleUnaryOperator fn); void applyOnFinite(DoubleUnaryOperator fn); void applyRecursively(final double initial, DoubleBinaryOperator fn); @Override boolean check(DoublePredicate pred); @Override int count(DoublePredicate pred); @Override int first(DoublePredicate pred); @Override int last(DoublePredicate pred); TsData transform(DoubleUnaryOperator fn); TsData transformFinite(DoubleUnaryOperator fn); TsData autoTransform(int lag, DoubleBinaryOperator fn); void apply(IReadDataBlock x, DoubleBinaryOperator fn); void applyOnFinite(IReadDataBlock x, DoubleBinaryOperator fn); void set(DoubleSupplier fn); void setIf(DoublePredicate pred, DoubleSupplier fn); void set(IntToDoubleFunction fn); void set(IReadDataBlock x, DoubleUnaryOperator fn); void set(IReadDataBlock x, IReadDataBlock y, DoubleBinaryOperator fn); static TsData computeOnIntersection(final TsData tsl, final TsData tsr, final DoubleBinaryOperator fn); }
TsData implements Cloneable, Iterable<TsObservation>, IReadDataBlock { public TsData drop(final int nfirst, final int nlast) { TsPeriod s = getStart(); s.move(nfirst); int n = vals.length - nfirst - nlast; if (n < 0) { n = 0; } TsData nts = new TsData(s, n); if (n == 0) { return nts; } int nc = n; int s0, t0; if (nfirst < 0) { nc += nfirst; t0 = -nfirst; s0 = 0; Arrays.fill(nts.vals, 0, -nfirst, Double.NaN); } else { s0 = nfirst; t0 = 0; } if (nlast < 0) { nc += nlast; Arrays.fill(nts.vals, nts.vals.length + nlast, nts.vals.length, Double.NaN); } if (nc > 0) { System.arraycopy(vals, s0, nts.vals, t0, nc); } return nts; } TsData(final TsDomain dom);  TsData(final TsDomain dom, double val);   TsData(final TsFrequency freq, final int beg, final int count);  TsData(final TsFrequency freq, final int firstyear,
            final int firstperiod, final double[] data, boolean copydata);  TsData(final TsFrequency freq, final int firstyear,
            final int firstperiod, final int count);  TsData(final TsPeriod start, final double[] data, boolean copydata);  TsData(final TsPeriod start, final int count);  TsData(final TsPeriod start, final IReadDataBlock vals); static TsData add(final double d, final TsData ts); static TsData add(final TsData tsl, final TsData tsr); static TsData divide(final double d, final TsData ts); static TsData divide(final TsData tsl, final TsData tsr); static TsData multiply(final double d, final TsData ts); static TsData multiply(final TsData tsl, final TsData tsr); static TsData subtract(double d, final TsData ts); static TsData subtract(final TsData tsl, final TsData tsr); static TsData random(TsFrequency freq); static TsData random(TsFrequency freq, int seed); void randomAirline(); double distance(TsData s); @Override void copyTo(double[] buffer, int start); @Override IReadDataBlock rextract(int start, int length); TsData abs(); TsData changeFrequency(final TsFrequency newfreq,
            final TsAggregationType conversion, final boolean complete); TsData chs(); TsData cleanExtremities(); @Override TsData clone(); TsData delta(final int lag); TsData delta(final int lag, final int power); TsData div(final double d); TsData div(final TsData ts); TsData drop(final int nfirst, final int nlast); TsData fullYears(); TsData exp(); TsData round(int ndec); TsData extend(final int nbefore, final int nafter); TsData extendTo(final Day lastday); TsData fittoDomain(final TsDomain dom); boolean isMissing(final int idx); void setMissing(final int idx); @Override double get(final int idx); @NewObject TsDomain getDomain(); @Deprecated Values getValues(); @NewObject TsPeriod getEnd(); TsFrequency getFrequency(); @NewObject TsPeriod getLastPeriod(); @Override int getLength(); int getObsCount(); int getMissingValuesCount(); boolean hasMissingValues(); @NewObject TsPeriod getStart(); TsData index(final TsPeriod refperiod, final double refvalue); TsData inv(); boolean isEmpty(); @Override Iterator<TsObservation> iterator(); Stream<TsObservation> stream(); TsData lag(int nperiods); TsData lead(final int nperiods); TsData log(); TsData log(final double b); TsData sqrt(); TsData minus(final double d); TsData minus(final TsData ts); TsData movingAverage(final double[] weights, final boolean bcentred,
            final boolean bnormalized); TsData movingMedian(final int nperiods, final boolean bcentred); TsData pctVariation(final int lag); TsData plus(final double d); TsData plus(final TsData ts); TsData pow(final double e); TsData select(final TsPeriodSelector ps); void set(final int idx, final double value); TsData times(final double d); TsData times(final TsData ts); TsData update(final TsData ts); static TsData concatenate(TsData l, TsData r); void removeMean(); void normalize(); double get(TsPeriod period); void set(TsPeriod period, double value); @Unsafe double[] internalStorage(); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); boolean equals(TsData other); @Override double computeRecursively(final double initial, DoubleBinaryOperator fn); void apply(DoubleUnaryOperator fn); void applyIf(DoublePredicate pred, DoubleUnaryOperator fn); void applyOnFinite(DoubleUnaryOperator fn); void applyRecursively(final double initial, DoubleBinaryOperator fn); @Override boolean check(DoublePredicate pred); @Override int count(DoublePredicate pred); @Override int first(DoublePredicate pred); @Override int last(DoublePredicate pred); TsData transform(DoubleUnaryOperator fn); TsData transformFinite(DoubleUnaryOperator fn); TsData autoTransform(int lag, DoubleBinaryOperator fn); void apply(IReadDataBlock x, DoubleBinaryOperator fn); void applyOnFinite(IReadDataBlock x, DoubleBinaryOperator fn); void set(DoubleSupplier fn); void setIf(DoublePredicate pred, DoubleSupplier fn); void set(IntToDoubleFunction fn); void set(IReadDataBlock x, DoubleUnaryOperator fn); void set(IReadDataBlock x, IReadDataBlock y, DoubleBinaryOperator fn); static TsData computeOnIntersection(final TsData tsl, final TsData tsr, final DoubleBinaryOperator fn);  }