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

tfw.immutable.ila.charila.StridedCharIlaFromCharIla Maven / Gradle / Ivy

Go to download

The FrameWork for building highly scalable and maintainable applications

The newest version!
package tfw.immutable.ila.charila;

import java.io.IOException;
import tfw.check.Argument;

public final class StridedCharIlaFromCharIla {
    private StridedCharIlaFromCharIla() {}

    public static StridedCharIla create(final CharIla ila, final char[] buffer) {
        Argument.assertNotNull(ila, "ila");
        Argument.assertNotNull(buffer, "buffer");

        return new StridedCharIlaImpl(ila, buffer);
    }

    private static class StridedCharIlaImpl extends AbstractStridedCharIla {
        private final CharIla ila;
        private final char[] buffer;

        public StridedCharIlaImpl(final CharIla ila, final char[] buffer) {
            this.ila = ila;
            this.buffer = buffer;
        }

        @Override
        public long lengthImpl() throws IOException {
            return ila.length();
        }

        @Override
        public void getImpl(final char[] array, final int offset, final int stride, final long start, int length)
                throws IOException {
            final CharIla segmentCharIla =
                    start == 0 && length == ila.length() ? ila : CharIlaSegment.create(ila, start, length);
            final CharIlaIterator bii = new CharIlaIterator(segmentCharIla, buffer.clone());

            for (int i = 0, ii = offset; i < length; i++, ii += stride) {
                array[ii] = bii.next();
            }
        }
    }
}
// AUTO GENERATED FROM TEMPLATE




© 2015 - 2024 Weber Informatics LLC | Privacy Policy