static void cppCopy(Collection a, List b) { ListIterator it = b.listIterator(); for (A x : a) { if (!it.hasNext()) fail("unexpected end of collection"); it.next(); it.set(x); } }