Created
April 18, 2012 11:29
-
-
Save reikje/2413000 to your computer and use it in GitHub Desktop.
Mimicking a circular buffer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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