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.stream.Stream; | |
public class TestHashCode { | |
public static void main(String[] args) { | |
Stream.generate(Object::new).mapToInt(Object::hashCode).mapToObj(Integer::toHexString) | |
.limit(20).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
public class RecursionTest { | |
static int count = 0; | |
public static void staticMethod() { | |
count++; | |
staticMethod(); | |
} | |
public static void staticMethod(int a) { | |
count++; |
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.TimeUnit; | |
import java.util.stream.*; | |
import static java.util.stream.Collectors.*; | |
import java.util.*; | |
import org.openjdk.jmh.infra.Blackhole; | |
import org.openjdk.jmh.annotations.*; | |
@Warmup(iterations = 5, 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
import java.util.concurrent.TimeUnit; | |
import static java.util.stream.Collectors.*; | |
import java.util.stream.*; | |
import java.util.function.*; | |
import java.util.*; | |
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
JDK flatMap | |
Thread[ForkJoinPool.commonPool-worker-7,5,main]=156250 | |
Thread[ForkJoinPool.commonPool-worker-4,5,main]=31250 | |
Thread[ForkJoinPool.commonPool-worker-1,5,main]=125000 | |
Thread[ForkJoinPool.commonPool-worker-6,5,main]=218750 | |
Thread[main,5,main]=62500 | |
Thread[ForkJoinPool.commonPool-worker-3,5,main]=125000 | |
Thread[ForkJoinPool.commonPool-worker-2,5,main]=125000 | |
Thread[ForkJoinPool.commonPool-worker-5,5,main]=156250 | |
Holger's flatMap |
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.TimeUnit; | |
import java.util.stream.*; | |
import java.util.*; | |
import org.openjdk.jmh.infra.Blackhole; | |
import org.openjdk.jmh.annotations.*; | |
@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
/* | |
Refactored by Tagir Valeev | |
Original code taken from | |
https://raw.githubusercontent.com/gorset/radix/master/Radix.java | |
Below is the original copyright notice | |
-------------- | |
Copyright 2011 Erik Gorset. All rights reserved. | |
Redistribution and use in source and binary forms, with or without modification, are | |
permitted provided that the following conditions are met: |
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.Collections; | |
import java.util.List; | |
import java.util.Objects; | |
import java.util.stream.IntStream; | |
import one.util.streamex.IntStreamEx; | |
import one.util.streamex.MoreCollectors; | |
public class FlatMapTest { |
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 test; | |
import java.util.concurrent.TimeUnit; | |
import java.util.stream.*; | |
import java.util.*; | |
import java.util.regex.*; | |
import org.openjdk.jmh.infra.Blackhole; | |
import org.openjdk.jmh.annotations.*; | |
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.List; | |
import one.util.streamex.IntStreamEx; | |
import one.util.streamex.StreamEx; | |
public class Readability { | |
public static void main(String args[]) { | |
// Sample 1 | |
List<Integer> list = Arrays.asList(1, 2, 3); |