IDEA-178788 Suggestion code replace from list iteration to List.removeAll

This commit is contained in:
Tagir Valeev
2017-09-13 09:38:22 +07:00
parent 89bc22ddf7
commit 35eb29010f
7 changed files with 25 additions and 47 deletions

View File

@@ -0,0 +1,10 @@
// "Replace iteration with bulk 'Collection.addAll' call" "true"
import java.util.*;
public class Collect {
static class Person {}
void collectNames(List<Person> persons, Collection<Person> toAdd){
persons.addAll(toAdd);
}
}

View File

@@ -1,10 +0,0 @@
// "Replace iteration with bulk 'List.removeAll' call" "true"
import java.util.*;
public class Collect {
static class Person {}
void collectNames(List<Person> persons, Collection<Person> toRemove){
persons.removeAll(toRemove);
}
}

View File

@@ -1,10 +0,0 @@
// "Replace iteration with bulk 'List.removeAll' call" "true"
import java.util.*;
public class Collect {
static class Person {}
void collectNames(List<Person> persons, Collection<Person> toRemove){
persons.removeAll(toRemove);
}
}

View File

@@ -0,0 +1,14 @@
// "Replace iteration with bulk 'Collection.addAll' call" "true"
import java.util.*;
public class Collect {
static class Person {}
void collectNames(List<Person> persons, Collection<Person> toAdd){
Iterator<Person> it = toAdd.iterator();
while (it.hasNext()) {
Person person = it.next();
persons<caret>.add(person);
}
}
}

View File

@@ -1,11 +0,0 @@
// "Replace iteration with bulk 'List.removeAll' call" "true"
import java.util.*;
public class Collect {
static class Person {}
void collectNames(List<Person> persons, Collection<Person> toRemove){
for (Iterator<Person> it = toRemove.iterator(); it.hasNext(); )
persons<caret>.remove(it.next());
}
}

View File

@@ -1,14 +0,0 @@
// "Replace iteration with bulk 'List.removeAll' call" "true"
import java.util.*;
public class Collect {
static class Person {}
void collectNames(List<Person> persons, Collection<Person> toRemove){
Iterator<Person> it = toRemove.iterator();
while (it.hasNext()) {
Person person = it.next();
persons<caret>.remove(person);
}
}
}