문제

I would like to flatten arbitrary deeply nested collections/structures of elements of some type T in Java, optimally with

  • only having a live view and not a copied collection;
  • not only handling Collections, but also Iterator, arrays of T of arbitrary dimension, Iterable, and all these structures arbitrarily mixed and nested;
  • statical type-safety.

Is there a java library which can handle this?


Guava seems to only handle one nesting level, i.e. Collection<Collection<T>> --flatten--> Collection<T>.

lambdaj looks promising: can I somehow combine on(), asIterator() and flattenIterator() to achieve this? In a statically type-safe manner?

올바른 솔루션이 없습니다

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top