SeqView implements Seq<T> { @Override public T get(final int index) { return _list.get(index); } SeqView(final List<? extends T> list); @SuppressWarnings("unchecked") @Override List<T> asList(); @Override T get(final int index); @Override int length(); @Override Seq<T> subSeq(final int start, final int end); @Override Seq<T> subSeq(final int start); @Override Seq<B> map(final Function<? super T, ? extends B> mapper); @Override Seq<T> append(final Iterable<? extends T> values); @Override Seq<T> prepend(final Iterable<? extends T> values); @Override Object[] toArray(); @Override B[] toArray(final B[] array);  }
@Test public void readThrough() { final int length = 100; final Random random = new Random(); final List<Integer> list = new ArrayList<>(length); for (int i = 0; i < length; ++i) { list.add(random.nextInt()); } final SeqView<Integer> view = new SeqView<>(list); for (int i = 0; i < length; ++i) { Assert.assertEquals(view.get(i), list.get(i)); } for (int i = 0; i < length; ++i) { list.set(i, random.nextInt()); } for (int i = 0; i < length; ++i) { Assert.assertEquals(view.get(i), list.get(i)); } }