Google Collections (Guava Libraries): ImmutableSet/List/Map and Filtering

后端 未结 2 965
轮回少年
轮回少年 2021-01-18 05:34

Assume that you want to build a copy of an ImmutableSet/List/Map object but filter out some of the original entries. One way to implem

相关标签:
2条回答
  • 2021-01-18 06:07

    Look at Guava's Iterators

    Specifically filter(Iterator unfiltered, Predicate predicate)

    0 讨论(0)
  • 2021-01-18 06:09

    The result of Iterables.filter() is just a view over the data in myObject: the new list is only built by ImmutableList.copyOf() using the filtering iterator provided by the Iterable

    0 讨论(0)
提交回复
热议问题