@Test public void testGet() { Series<String> s = new OffsetLagSeries<>(Series.forData("a", "b", "c", "d"), -1, "X"); assertThrows(ArrayIndexOutOfBoundsException.class, () -> s.get(-1)); assertEquals("b", s.get(0)); assertEquals("c", s.get(1)); assertEquals("d", s.get(2)); assertEquals("X", s.get(3)); assertThrows(ArrayIndexOutOfBoundsException.class, () -> s.get(4)); }
@Override public T get(int index) { int size = size(); if (index >= size || index < 0) { throw new ArrayIndexOutOfBoundsException(index); } return index < size + offset ? delegate.get(index - offset) : filler; }
OffsetLagSeries extends OffsetSeries<T> { @Override public T get(int index) { int size = size(); if (index >= size || index < 0) { throw new ArrayIndexOutOfBoundsException(index); } return index < size + offset ? delegate.get(index - offset) : filler; } }
OffsetLagSeries extends OffsetSeries<T> { @Override public T get(int index) { int size = size(); if (index >= size || index < 0) { throw new ArrayIndexOutOfBoundsException(index); } return index < size + offset ? delegate.get(index - offset) : filler; } OffsetLagSeries(Series<T> delegate, int offset, T filler); }
OffsetLagSeries extends OffsetSeries<T> { @Override public T get(int index) { int size = size(); if (index >= size || index < 0) { throw new ArrayIndexOutOfBoundsException(index); } return index < size + offset ? delegate.get(index - offset) : 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 T get(int index) { int size = size(); if (index >= size || index < 0) { throw new ArrayIndexOutOfBoundsException(index); } return index < size + offset ? delegate.get(index - offset) : 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();  }