TaggedReiteratorList extends AbstractList<Reiterator<Object>> { @Override public Reiterator<Object> get(int tag) { return new SubIterator(tag); } <T> TaggedReiteratorList(Reiterator<T> taggedReiterator, TagExtractor<T> extractor); @SuppressWarnings({"unchecked", "rawtypes"}) <T> TaggedReiteratorList(
      Reiterator<T> taggedReiterator, TagExtractor<T> extractor, int size); @Override Reiterator<Object> get(int tag); @Override int size();  }
@Test public void testSingleIterator() { TaggedReiteratorList iter = create(new String[] {"a", "b", "c"}); assertEquals(iter.get(0), "a", "b", "c"); assertEquals(iter.get(0), "a", "b", "c"); assertEquals(iter.get(1) ); assertEquals(iter.get(0), "a", "b", "c"); }
@Test public void testSequentialAccess() { TaggedReiteratorList iter = create(3, new String[] {"a", "b", "c"}); for (int i = 0; i < 2; i++) { assertEquals(iter.get(0), "a0", "b0", "c0"); assertEquals(iter.get(1), "a1", "b1", "c1"); assertEquals(iter.get(2), "a2", "b2", "c2"); } for (int i = 0; i < 2; i++) { assertEquals(iter.get(2), "a2", "b2", "c2"); assertEquals(iter.get(1), "a1", "b1", "c1"); assertEquals(iter.get(0), "a0", "b0", "c0"); } }
@Test public void testRandomAccess() { TaggedReiteratorList iter = create(6, new String[] {"a", "b"}); assertEquals(iter.get(3), "a3", "b3"); assertEquals(iter.get(1), "a1", "b1"); assertEquals(iter.get(5), "a5", "b5"); assertEquals(iter.get(0), "a0", "b0"); assertEquals(iter.get(4), "a4", "b4"); assertEquals(iter.get(4), "a4", "b4"); assertEquals(iter.get(1), "a1", "b1"); }
@Test public void testPartialIteration() { TaggedReiteratorList iter = create(6, new String[] {"a", "b", "c"}); Iterator<?> get0 = iter.get(0); Iterator<?> get1 = iter.get(1); Iterator<?> get3 = iter.get(3); assertEquals(asList(get0, 1), "a0"); assertEquals(asList(get1, 2), "a1", "b1"); assertEquals(asList(get3, 3), "a3", "b3", "c3"); Iterator<?> get2 = iter.get(2); Iterator<?> get0Again = iter.get(0); assertEquals(asList(get0, 1), "b0"); assertEquals(get2, "a2", "b2", "c2"); assertEquals(get0Again, "a0", "b0", "c0"); assertEquals(asList(get0), "c0"); Iterator<?> get4 = iter.get(4); assertEquals(get4, "a4", "b4", "c4"); assertEquals(get4 ); assertEquals(iter.get(4), "a4", "b4", "c4"); }
@Test public void testNextIteration() { TaggedReiteratorList iter = create(2, new String[] {"a", "b", "c"}); Reiterator<?> get0 = iter.get(0); assertEquals(get0, "a0", "b0", "c0"); Iterator<?> get1 = iter.get(1); Assert.assertEquals("a1", get1.next()); assertEquals(get0.copy() ); Assert.assertEquals("b1", get1.next()); assertEquals(iter.get(1), "a1", "b1", "c1"); }
@Test public void testEmpties() { TaggedReiteratorList iter = create( new String[] {}, new String[] {"a", "b", "c"}, new String[] {}, new String[] {}, new String[] {"d"}); assertEquals(iter.get(2) ); assertEquals(iter.get(1), "a", "b", "c"); assertEquals(iter.get(2) ); assertEquals(iter.get(0) ); assertEquals(iter.get(2) ); assertEquals(iter.get(4), "d"); assertEquals(iter.get(3) ); }