ResizableDoubleArray implements DoubleArray, Serializable { public double compute(MathArrays.Function f) { final double[] array; final int start; final int num; synchronized(this) { array = internalArray; start = startIndex; num = numElements; } return f.evaluate(array, start, num); } ResizableDoubleArray();  ResizableDoubleArray(int initialCapacity);  ResizableDoubleArray(double[] initialArray); @Deprecated  ResizableDoubleArray(int initialCapacity,
                                float expansionFactor);  ResizableDoubleArray(int initialCapacity,
                                double expansionFactor); @Deprecated  ResizableDoubleArray(int initialCapacity,
                                float expansionFactor,
                                float contractionCriteria);  ResizableDoubleArray(int initialCapacity,
                                double expansionFactor,
                                double contractionCriterion); @Deprecated  ResizableDoubleArray(int initialCapacity, float expansionFactor,
            float contractionCriteria, int expansionMode);  ResizableDoubleArray(int initialCapacity,
                                double expansionFactor,
                                double contractionCriterion,
                                ExpansionMode expansionMode,
                                double ... data);  ResizableDoubleArray(ResizableDoubleArray original); synchronized void addElement(double value); synchronized void addElements(double[] values); synchronized double addElementRolling(double value); synchronized double substituteMostRecentElement(double value); synchronized void clear(); synchronized void contract(); synchronized void discardFrontElements(int i); synchronized void discardMostRecentElements(int i); @Deprecated float getContractionCriteria(); double getContractionCriterion(); synchronized double getElement(int index); synchronized double[] getElements(); @Deprecated float getExpansionFactor(); @Deprecated int getExpansionMode(); int getCapacity(); synchronized int getNumElements(); @Deprecated synchronized double[] getInternalValues(); @Deprecated void setContractionCriteria(float contractionCriteria); double compute(MathArrays.Function f); synchronized void setElement(int index, double value); @Deprecated void setExpansionFactor(float expansionFactor); @Deprecated void setExpansionMode(int expansionMode); @Deprecated void setExpansionMode(ExpansionMode expansionMode); synchronized void setNumElements(int i); @Deprecated synchronized int start(); static void copy(ResizableDoubleArray source,
                            ResizableDoubleArray dest); synchronized ResizableDoubleArray copy(); @Override boolean equals(Object object); @Override synchronized int hashCode(); @Deprecated
    static final int ADDITIVE_MODE; @Deprecated
    static final int MULTIPLICATIVE_MODE; }
@Test public void testCompute() { final ResizableDoubleArray a = new ResizableDoubleArray(); final int max = 20; for (int i = 1; i <= max; i++) { a.setElement(i, i); } final MathArrays.Function add = new MathArrays.Function() { public double evaluate(double[] a, int index, int num) { double sum = 0; final int max = index + num; for (int i = index; i < max; i++) { sum += a[i]; } return sum; } public double evaluate(double[] a) { return evaluate(a, 0, a.length); } }; final double sum = a.compute(add); Assert.assertEquals(0.5 * max * (max + 1), sum, 0); }