mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Java8CollectionRemoveIf: testdata fixed (IDEA-214448)
GitOrigin-RevId: e9d934fc8d31016744f2302c39651eb6ecfa4de7
This commit is contained in:
committed by
intellij-monorepo-bot
parent
fc57b9d181
commit
aeeb1ebd38
+1
-3
@@ -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);
|
||||
}
|
||||
}
|
||||
+2
-4
@@ -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);
|
||||
}
|
||||
}
|
||||
+1
-3
@@ -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);
|
||||
}
|
||||
}
|
||||
+1
-3
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user