All Downloads are FREE. Search and download functionalities are using the official Maven repository.

tfw.immutable.ila.doubleila.DoubleIlaFromCastIntIla Maven / Gradle / Ivy

package tfw.immutable.ila.doubleila;

import tfw.check.Argument;
import tfw.immutable.DataInvalidException;
import tfw.immutable.ila.intila.IntIla;
import tfw.immutable.ila.intila.IntIlaIterator;
import tfw.immutable.ila.intila.IntIlaSegment;

public final class DoubleIlaFromCastIntIla {
    private DoubleIlaFromCastIntIla() {
        // non-instantiable class
    }

    public static DoubleIla create(IntIla intIla, int bufferSize) {
        Argument.assertNotNull(intIla, "intIla");
        Argument.assertNotLessThan(bufferSize, 1, "bufferSize");

        return new MyDoubleIla(intIla, bufferSize);
    }

    private static class MyDoubleIla extends AbstractDoubleIla {
        private final IntIla intIla;
        private final int bufferSize;

        MyDoubleIla(IntIla intIla, int bufferSize) {
            super(intIla.length());

            this.intIla = intIla;
            this.bufferSize = bufferSize;
        }

        protected void toArrayImpl(double[] array, int offset, long start, int length) throws DataInvalidException {
            IntIlaIterator fi = new IntIlaIterator(IntIlaSegment.create(intIla, start, length), new int[bufferSize]);

            for (int ii = offset; length > 0; ii++, --length) {
                array[ii] = (double) fi.next();
            }
        }
    }
}
// AUTO GENERATED FROM TEMPLATE




© 2015 - 2024 Weber Informatics LLC | Privacy Policy