mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-26 00:11:26 +07:00
StreamToLoop: special handling of max().orElse(MIN_VALUE), etc.
This commit is contained in:
+20
@@ -104,6 +104,26 @@ public class Main {
|
||||
return seen ? best : supplier.getAsInt();
|
||||
}
|
||||
|
||||
public static int testMinMaxValue(List<String> strings) {
|
||||
int best = Integer.MAX_VALUE;
|
||||
for (String string : strings) {
|
||||
int length = string.length();
|
||||
if (length < best)
|
||||
best = length;
|
||||
}
|
||||
return best;
|
||||
}
|
||||
|
||||
public static long testMaxMinValue(List<String> strings) {
|
||||
long max = Long.MIN_VALUE;
|
||||
for (String string : strings) {
|
||||
long length = string.length();
|
||||
if (length > max)
|
||||
max = length;
|
||||
}
|
||||
return max;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(testMaxComparator(Arrays.asList()));
|
||||
System.out.println(testMaxComparator(Arrays.asList("a", "bbb", "cc", "d", "eee")));
|
||||
|
||||
+9
@@ -36,6 +36,15 @@ public class Main {
|
||||
return strings.stream().mapToInt(String::length).min().orElseGet(supplier);
|
||||
}
|
||||
|
||||
public static int testMinMaxValue(List<String> strings) {
|
||||
return strings.stream().mapToInt(String::length).min().orElse(Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
public static long testMaxMinValue(List<String> strings) {
|
||||
long max = strings.stream().mapToLong(String::length).max().orElse(Long.MIN_VALUE);
|
||||
return max;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(testMaxComparator(Arrays.asList()));
|
||||
System.out.println(testMaxComparator(Arrays.asList("a", "bbb", "cc", "d", "eee")));
|
||||
|
||||
Reference in New Issue
Block a user