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.mehdi.main.codeforces.edu_47; | |
import com.mehdi.lib.io.InputReader; | |
import java.io.PrintWriter; | |
import static com.mehdi.lib.Factories.*; | |
public class TaskC { | |
public void solve(int testNumber, InputReader in, PrintWriter out) { |
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.runner.Runner; | |
import org.openjdk.jmh.runner.RunnerException; | |
import org.openjdk.jmh.runner.options.Options; | |
import org.openjdk.jmh.runner.options.OptionsBuilder; | |
public class TestRunner { | |
public static void main(String[] args) throws RunnerException { | |
Options options = new OptionsBuilder().include(StreamBenchmark.class.getSimpleName()) |
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 static java.util.stream.Collectors.toList; | |
import java.util.Arrays; | |
import java.util.List; | |
import java.util.concurrent.TimeUnit; | |
import org.openjdk.jmh.annotations.Benchmark; | |
import org.openjdk.jmh.annotations.OutputTimeUnit; | |
import org.openjdk.jmh.annotations.Scope; | |
import org.openjdk.jmh.annotations.State; |
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
IntStream.range(0, 10).parallel().forEachOrdered(e -> { | |
try { | |
Thread.sleep(300); | |
System.out.println("iteration " + e); | |
} catch (InterruptedException e1) { | |
e1.printStackTrace(); | |
} | |
}); | |
System.out.println("finished"); |
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
IntStream.range(0, 100).parallel().map(e -> e * 3).forEach(System.out::println); |
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
IntStream.range(0, 10).parallel().forEach(e -> { | |
try { | |
Thread.sleep(300); | |
System.out.println("the current working thred " + Thread.currentThread().getName()); | |
} catch (InterruptedException ex) { | |
ex.printStackTrace(); | |
} | |
}); |
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
List<Double> stockChanges = new ArrayList<>(); | |
stocks.paralllelStream().map(Stock::getChange).forEach(e -> stockChanges.add(e)) |
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
List<Stock> stocks = getStockList(); | |
stocks.parallelStream().map(Stock::getChange).reduce(0.0, (acc, val) -> acc + val); |
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.io.OutputStream; | |
import java.io.IOException; | |
import java.io.InputStream; | |
import java.io.PrintWriter; | |
import java.util.stream.IntStream; | |
import java.io.IOException; | |
import java.util.InputMismatchException; | |
import java.util.stream.Stream; | |
import java.util.Comparator; | |
import java.io.InputStream; |