【发布时间】:2014-11-11 20:02:34
【问题描述】:
我想将流放入不可变列表中。以下方法之间有什么区别,从性能角度来看哪一种更好?
collect( Collectors.collectingAndThen(Collectors.toList(), ImmutableList::copyOf));ImmutableList.copyOf( stream.iterator() );collect( Collector.of( ImmutableList.Builder<Path>::new, ImmutableList.Builder<Path>::add, (l, r) -> l.addAll(r.build()), ImmutableList.Builder<Path>::build) );
关于性能或效率的更多参数,
列表/集合中可能有很多条目。
如果我想对集合进行排序,使用中间操作
".sorted()"和自定义比较器。- 因此,如果我将
.parallel()添加到流中会怎样
【问题讨论】:
标签: java java-8 guava java-stream