How do I sort a List of TreeSets with java8 streams

前端 未结 3 1528
陌清茗
陌清茗 2021-01-12 09:01

My list contains sets like [1,3,5][2,6,4] etc, all of the same size. I tried doing this but it doesn\'t seem to work.

List&g         


        
3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-12 09:12

    If you have guava on the classpath this is a breeze:

            block
                .stream()
                .flatMap(Set::stream)
                .collect(Collectors.toCollection(TreeSet::new));
    
        Iterable> result = Iterables.partition(sorted, 3);
    

提交回复
热议问题