a-foundation/src/main/java/com/ajjpj/afoundation/collection/ACollectionHelper.java
public static <T, X, E extends Throwable> Set<X> flatMapSet(Iterable<T> coll, AFunction1<? super T, ? extends Iterable<X>, E> f) throws E {
        final Set<X> result = new HashSet<>();

        for(T o: coll) {
            for(X el: f.apply(o)) {
                result.add(el);
            }
        }

        return result;
    }
public static <T, X, E extends Throwable> Set<X> flatMapSet(Iterable<T> coll, AFunction1<? super T, ? extends Iterable<X>, E> f) throws E {
        final Set<X> result = new HashSet<>();

        for(T o: coll) {
            for(X el: f.apply(o)) {
                result.add(el);
            }
        }

        return result;
    }
public static < T , X , E extends Throwable > Set < X > flatMapSet ( Iterable < T > coll , AFunction1 < ? super T , ? extends Iterable < X > , E > f ) throws E { final Set < X > result = new HashSet <> ( ) ; for ( T o : coll ) { for ( X el : f . apply ( o ) ) { result . add ( el ) ; } } return result ; }
Same as <code>map()</code>, except that the transformation function returns collections and all the results are
flattened into a single collection.
Same as <code > map () < / code > except that the transformation function returns collections and all the results are flattened into a single collection .