Files
openide/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamToLoop/afterSkipDistinctCount.java
Tagir Valeev 7e1064ea3c [java-intentions] More preview tests; minor fixes
GitOrigin-RevId: 22a46c15d8900d8a31514846755a013f6a67ad42
2022-07-29 17:55:13 +00:00

25 lines
585 B
Java

// "Replace Stream API chain with loop" "true-preview"
import java.util.*;
public class Main {
private static long test(List<?> list) {
long count = 0L;
Set<Object> uniqueValues = new HashSet<>();
long toSkip = list.size() / 2;
for (Object o : list) {
if (toSkip > 0) {
toSkip--;
continue;
}
if (uniqueValues.add(o)) {
count++;
}
}
return count;
}
public static void main(String[] args) {
System.out.println(test(Arrays.asList(1,2,3,3,2,1,1,2,3)));
}
}