Created
May 20, 2018 15:11
-
-
Save ThanawatMas/34807797220c062796e01bc108f12470 to your computer and use it in GitHub Desktop.
SolveByIterator.java
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
public class SolveByIterator extends ConcurrentModificationSolution { | |
@Override | |
public void addItemAndReIndex(List<String> roundItem, String newItem) { | |
Iterator iterator = roundItem.iterator(); | |
while(iterator.hasNext()) { | |
String item = (String) iterator.next(); | |
if(item.equals(newItem)) { | |
iterator.remove(); | |
break; | |
} | |
} | |
roundItem.add(0, newItem); | |
} | |
@Override | |
public String solutionName() { | |
return "Iterator"; | |
} | |
public static void main(String[] args) { | |
SolveByIterator iterator = new SolveByIterator(); | |
iterator.solve(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment