Last active
January 23, 2018 23:37
-
-
Save andras-gyarmati/886fdb3188cd7e5b32625a8b5e64e243 to your computer and use it in GitHub Desktop.
processing remove items from arraylist while iterating
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
| void foo() { | |
| if (list.size() > 0) { | |
| boolean finished = false; | |
| int i = 0; | |
| Bar b; | |
| while (!finished) { | |
| b = list.get(i); | |
| if (b.condition == whatever) { | |
| list.remove(b); | |
| } else { | |
| i++; | |
| } | |
| if (i >= list.size()) { | |
| finished = true; | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment