Skip to content

Instantly share code, notes, and snippets.

@reikje
Created April 18, 2012 11:29
Show Gist options
  • Select an option

  • Save reikje/2413000 to your computer and use it in GitHub Desktop.

Select an option

Save reikje/2413000 to your computer and use it in GitHub Desktop.
Mimicking a circular buffer
// create a cyclic iterator
final Iterator<Element> cycle = Iterators.cycle(elements);
while (cycle.hasNext()) {
final Element e = cycle.next();
// do stuff with e
cycle.remove();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment