Skip to content

Instantly share code, notes, and snippets.

@zhangsida
zhangsida / scratch_121.txt
Created May 15, 2019 07:33 — forked from ibalashov/scratch_121.txt
List vs HashSet performance for small lists (single contains op)
public static List<Integer> generate(int series) {
return Stream.iterate(new int[]{0, 1}, s -> new int[]{s[1], s[0] + s[1]})
.limit(series)
.map(n -> n[0])
.collect(Collectors.toList());
}
public static void main(String[] args) {
generate(30).forEach(n -> {
List<String> collected = Stream.generate(() -> UUID.randomUUID().toString()).limit(n).collect(Collectors.toList());