Java8CollectionRemoveIf: testdata fixed (IDEA-214448)

GitOrigin-RevId: e9d934fc8d31016744f2302c39651eb6ecfa4de7
This commit is contained in:
Tagir Valeev
2019-07-02 06:52:16 +03:00
committed by intellij-monorepo-bot
parent fc57b9d181
commit aeeb1ebd38
4 changed files with 5 additions and 13 deletions
@@ -4,8 +4,6 @@ import java.util.*;
public class Main {
public void removeEmpty(List<String> list) throws Exception {
// Copy to avoid CME
for(<caret>String item : new ArrayList<>(list)) {
if(item.isEmpty()) list.remove(item);
}
list.removeIf(String::isEmpty);
}
}
@@ -3,9 +3,7 @@ import java.util.*;
public class Main {
public void removeEmpty(List<String> list) throws Exception {
for(<caret>String item : list) {
// Presumably CopyOnWriteArrayList
if(item.isEmpty()) list.remove(item);
}
// Presumably CopyOnWriteArrayList
list.removeIf(String::isEmpty);
}
}
@@ -4,8 +4,6 @@ import java.util.*;
public class Main {
public void removeEmpty(List<String> list) throws Exception {
// Copy to avoid CME
for(<caret>String item : list.toArray(new String[list.size()])) {
if(item.isEmpty()) list.remove(item);
}
list.removeIf(String::isEmpty);
}
}
@@ -4,8 +4,6 @@ import java.util.List;
public class Main {
public void testIterator(List<List<String>> data, boolean b) {
for(Ite<caret>rator<List<String>> iter = (data.iterator()); iter.hasNext();)
if(iter.next().isEmpty() && /* also check the flag */ b)
iter.remove();
data.removeIf(strings -> strings.isEmpty() && /* also check the flag */ b);
}
}