我有兩個java名單如下:連接兩個Java流
"type 1" list:
[(id:1, type: 1, value: 100), (id:2, type: 1, value: 50), ...]
"type 2" list:
[(id:1, type: 2, value: 150), (id:2, type: 2, value: 70), ...]
而且我希望這樣的事情:
Stream.concat(list1.stream(), list2.stream())
.collect(groupingBy(x -> x.getItem)).values().stream()
.map (listOftwo -> ....)
:
Stream.concat(list1.stream(), list2.stream())
.parallel()
// I need to combine somehow items with the same id for following process
// ideally to have Tuple2(l1item, l2item) after that
.groupBy(x -> x.getId())
.map ((l1item, l2item) -> {
// some processing
}).collect(Collectors.toList())
AFAIK它可以通過實施但我不想要那張中間地圖。有任何想法嗎 ?我可以使用任何庫。
感謝
看起來很有趣,謝謝 – Normal