static IterableIterator shuffledIterator(fL l) { new Map shuffled; ret new IterableIterator() { int n = l(l); int i = 0; public bool hasNext() { ret i < n; } public A next() { int j = random(i, n); A a = get(i), b = get(j); shuffled.put(j, a); shuffled.put(i, b); ret b; } A get(int i) { ret shuffled.containsKey(i) ? shuffled.get(i) : l.get(i); } }; }