tfw.immutable.ila.floatila.FloatIlaRemove Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tfw Show documentation
Show all versions of tfw Show documentation
The FrameWork for building highly scalable and maintainable applications
The newest version!
package tfw.immutable.ila.floatila;
import java.io.IOException;
import tfw.check.Argument;
public final class FloatIlaRemove {
private FloatIlaRemove() {
// non-instantiable class
}
public static FloatIla create(FloatIla ila, long index) throws IOException {
Argument.assertNotNull(ila, "ila");
Argument.assertNotLessThan(index, 0, "index");
Argument.assertLessThan(index, ila.length(), "index", "ila.length()");
return new FloatIlaImpl(ila, index);
}
private static class FloatIlaImpl extends AbstractFloatIla {
private final FloatIla ila;
private final long index;
private FloatIlaImpl(FloatIla ila, long index) {
this.ila = ila;
this.index = index;
}
@Override
protected long lengthImpl() throws IOException {
return ila.length() - 1;
}
@Override
protected void getImpl(float[] array, int offset, long start, int length) throws IOException {
final long startPlusLength = start + length;
if ((index - 1) < start) {
ila.get(array, offset, start + 1, length);
} else if ((index + 1) > startPlusLength) {
ila.get(array, offset, start, length);
} else {
final int indexMinusStart = (int) (index - start);
ila.get(array, offset, start, indexMinusStart);
ila.get(array, offset + indexMinusStart, index + 1, length - indexMinusStart);
}
}
}
}
// AUTO GENERATED FROM TEMPLATE