mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-18 00:20:54 +07:00
35 lines
938 B
Java
35 lines
938 B
Java
// "Fix all 'Stream API call chain can be replaced with loop' problems in file" "true"
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.HashSet;
|
|
import java.util.List;
|
|
import java.util.Set;
|
|
import java.util.stream.*;
|
|
|
|
public class Main {
|
|
public long testCount(List<String> list) {
|
|
long count = 0L;
|
|
Set<String> uniqueValues = new HashSet<>();
|
|
for (String s : list) {
|
|
if (uniqueValues.add(s)) {
|
|
count++;
|
|
}
|
|
}
|
|
return count;
|
|
}
|
|
|
|
private static List<Object> testToList(List<? extends Number> numbers) {
|
|
List<Object> list = new ArrayList<>();
|
|
Set<Number> uniqueValues = new HashSet<>();
|
|
for (Number number : numbers) {
|
|
if (uniqueValues.add(number)) {
|
|
list.add(number);
|
|
}
|
|
}
|
|
return list;
|
|
}
|
|
|
|
public static void main(String[] args) {
|
|
System.out.println(testToList(Arrays.asList(1,2,3,5,3,2,2,2,1,1,4,3)));
|
|
}
|
|
} |