@Override
  public T get(int idx) {
    if (idx < 0) {
      throw new IndexOutOfBoundsException();
    }
    int base = 0;
    Iterator<List<T>> it = chunks.iterator();
    while (it.hasNext()) {
      List<T> list = it.next();
      int size = list.size();
      if (idx < base + size) {
        return list.get(idx - base);
      }
      base += size;
    }
    throw new IndexOutOfBoundsException();
  }
@Test
  public void testGet() throws Exception {
    final int NUM_ELEMS = 100001;
    ChunkedArrayList<Integer> list = new ChunkedArrayList<Integer>();
    for (int i = 0; i < NUM_ELEMS; i++) {
      list.add(i);
    }

    Assert.assertEquals(Integer.valueOf(100), list.get(100));
    Assert.assertEquals(Integer.valueOf(1000), list.get(1000));
    Assert.assertEquals(Integer.valueOf(10000), list.get(10000));
    Assert.assertEquals(Integer.valueOf(100000), list.get(100000));

    Iterator<Integer> iter = list.iterator();
    iter.next();
    iter.remove();
    Assert.assertEquals(Integer.valueOf(1), list.get(0));

    iter = list.iterator();
    for (int i = 0; i < 500; i++) {
      iter.next();
    }
    iter.remove();

    Assert.assertEquals(Integer.valueOf(502), list.get(500));
    Assert.assertEquals(Integer.valueOf(602), list.get(600));
  }