@Test public void testCopyTo() { Series<String> s = new OffsetLagSeries<>(Series.forData("a", "b", "c", "d"), -1, "X"); Object[] b1 = new Object[5]; s.copyTo(b1, 0, 1, 4); assertArrayEquals(new Object[]{null, "b", "c", "d", "X"}, b1); Object[] b2 = new Object[5]; s.copyTo(b2, 1, 1, 3); assertArrayEquals(new Object[]{null, "c", "d", "X", null}, b2); Object[] b3 = new Object[5]; s.copyTo(b3, 3, 1, 1); assertArrayEquals(new Object[]{null, "X", null, null, null}, b3); }
@Override public void copyTo(Object[] to, int fromOffset, int toOffset, int len) { int size = size(); if (fromOffset + len > size) { throw new ArrayIndexOutOfBoundsException(fromOffset + len); } int len1 = Math.min(size + offset - fromOffset, len); int len2 = len - len1; int off1 = fromOffset - offset; if (len1 > 0) { delegate.copyTo(to, off1, toOffset, len1); } if (len2 > 0) { Arrays.fill(to, toOffset + len1, toOffset + len, filler); } }
OffsetLagSeries extends OffsetSeries<T> { @Override public void copyTo(Object[] to, int fromOffset, int toOffset, int len) { int size = size(); if (fromOffset + len > size) { throw new ArrayIndexOutOfBoundsException(fromOffset + len); } int len1 = Math.min(size + offset - fromOffset, len); int len2 = len - len1; int off1 = fromOffset - offset; if (len1 > 0) { delegate.copyTo(to, off1, toOffset, len1); } if (len2 > 0) { Arrays.fill(to, toOffset + len1, toOffset + len, filler); } } }
OffsetLagSeries extends OffsetSeries<T> { @Override public void copyTo(Object[] to, int fromOffset, int toOffset, int len) { int size = size(); if (fromOffset + len > size) { throw new ArrayIndexOutOfBoundsException(fromOffset + len); } int len1 = Math.min(size + offset - fromOffset, len); int len2 = len - len1; int off1 = fromOffset - offset; if (len1 > 0) { delegate.copyTo(to, off1, toOffset, len1); } if (len2 > 0) { Arrays.fill(to, toOffset + len1, toOffset + len, filler); } } OffsetLagSeries(Series<T> delegate, int offset, T filler); }
OffsetLagSeries extends OffsetSeries<T> { @Override public void copyTo(Object[] to, int fromOffset, int toOffset, int len) { int size = size(); if (fromOffset + len > size) { throw new ArrayIndexOutOfBoundsException(fromOffset + len); } int len1 = Math.min(size + offset - fromOffset, len); int len2 = len - len1; int off1 = fromOffset - offset; if (len1 > 0) { delegate.copyTo(to, off1, toOffset, len1); } if (len2 > 0) { Arrays.fill(to, toOffset + len1, toOffset + len, filler); } } OffsetLagSeries(Series<T> delegate, int offset, T filler); @Override Series<T> shift(int offset, T filler); @Override T get(int index); @Override void copyTo(Object[] to, int fromOffset, int toOffset, int len); @Override Series<T> materialize(); }
OffsetLagSeries extends OffsetSeries<T> { @Override public void copyTo(Object[] to, int fromOffset, int toOffset, int len) { int size = size(); if (fromOffset + len > size) { throw new ArrayIndexOutOfBoundsException(fromOffset + len); } int len1 = Math.min(size + offset - fromOffset, len); int len2 = len - len1; int off1 = fromOffset - offset; if (len1 > 0) { delegate.copyTo(to, off1, toOffset, len1); } if (len2 > 0) { Arrays.fill(to, toOffset + len1, toOffset + len, filler); } } OffsetLagSeries(Series<T> delegate, int offset, T filler); @Override Series<T> shift(int offset, T filler); @Override T get(int index); @Override void copyTo(Object[] to, int fromOffset, int toOffset, int len); @Override Series<T> materialize();  }