This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.example; | |
| import org.openjdk.jmh.annotations.*; | |
| import java.util.*; | |
| import java.util.concurrent.*;import java.util.function.Supplier;import java.util.stream.Collectors;import java.util.stream.IntStream; | |
| @Fork(3) | |
| @Warmup(iterations=10, time=500, timeUnit=TimeUnit.MILLISECONDS) | |
| @Measurement(iterations=10, time=500, timeUnit=TimeUnit.MILLISECONDS) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class February31 { | |
| public static final int[] kDaysInMonth = { | |
| 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 | |
| }; | |
| boolean ValidateDateTime(DateTime time) { | |
| if (time.year < 1 || time.year > 9999 || | |
| time.month < 1 || time.month > 12 || | |
| time.day < 1 || time.day > 31 || | |
| time.hour < 0 || time.hour > 23 || |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.*; | |
| public class February31 { | |
| private static final int[] kDaysInMonth = { | |
| 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 | |
| }; | |
| boolean ValidateDateTime(DateTime time) { | |
| if (time.year < 1 || time.year > 9999 || | |
| time.month < 1 || time.month > 12 || |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import org.openjdk.jmh.annotations.*; | |
| import java.util.*; | |
| import java.util.concurrent.TimeUnit; | |
| import java.util.stream.*; | |
| @BenchmarkMode(Mode.AverageTime) | |
| @Warmup(iterations = 5, time = 500, timeUnit = TimeUnit.MILLISECONDS) | |
| @Measurement(iterations = 5, time = 500, timeUnit = TimeUnit.MILLISECONDS) | |
| @OutputTimeUnit(TimeUnit.NANOSECONDS) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import one.util.streamex.EntryStream; | |
| import one.util.streamex.StreamEx; | |
| import java.util.*; | |
| public class Test { | |
| static List<List<Integer>> mergeCollections(List<List<Integer>> input) { | |
| return StreamEx.of(input).foldLeft(Collections.emptyList(), | |
| (List<List<Integer>> acc, List<Integer> listInner) -> EntryStream | |
| .of(StreamEx.of(acc).partitioningBy(list -> list.stream().anyMatch(listInner::contains))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import org.openjdk.jmh.annotations.*; | |
| import java.lang.reflect.InvocationTargetException; | |
| import java.lang.reflect.Method; | |
| import java.util.concurrent.TimeUnit; | |
| @Fork(3) | |
| @Warmup(iterations = 5, time = 500, timeUnit = TimeUnit.MILLISECONDS) | |
| @Measurement(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS) | |
| @BenchmarkMode(Mode.AverageTime) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import org.openjdk.jmh.annotations.*; | |
| import java.io.Serializable; | |
| import java.lang.invoke.SerializedLambda; | |
| import java.lang.reflect.Method; | |
| import java.util.*; | |
| import java.util.concurrent.TimeUnit; | |
| import java.util.function.Function; | |
| import java.util.stream.Collectors; | |
| import java.util.stream.Stream; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.*; | |
| import java.util.function.*; | |
| import java.util.stream.*; | |
| import java.util.concurrent.TimeUnit; | |
| import org.openjdk.jmh.annotations.*; | |
| import org.openjdk.jmh.runner.Runner; | |
| import org.openjdk.jmh.runner.RunnerException; | |
| import org.openjdk.jmh.runner.options.Options; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.concurrent.*; | |
| import java.util.stream.*; | |
| import java.util.function.*; | |
| import java.util.*; | |
| import one.util.streamex.*; | |
| import org.openjdk.jmh.infra.Blackhole; | |
| import org.openjdk.jmh.annotations.*; | |
| @Warmup(iterations = 5, time = 500, timeUnit = TimeUnit.MILLISECONDS) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.Arrays; | |
| import java.util.Comparator; | |
| import java.util.Optional; | |
| import java.util.function.BinaryOperator; | |
| import java.util.function.Consumer; | |
| import java.util.function.Function; | |
| import java.util.function.Predicate; | |
| public interface MyStream<T> { | |
| void forEach(Consumer<T> cons); |