public static < T , P , A , R extends Collection < A > > R collectWith ( Iterable < T > iterable , Function2 < ? super T , ? super P , ? extends A > function , P parameter , R targetCollection ) { if ( iterable instanceof RichIterable ) { return ( ( RichIterable < T > ) iterable ) . collectWith ( function , parameter , targetCollection ) ; } if ( iterable instanceof ArrayList ) { return ArrayListIterate . collectWith ( ( ArrayList < T > ) iterable , function , parameter , targetCollection ) ; } if ( iterable instanceof RandomAccess ) { return RandomAccessListIterate . collectWith ( ( List < T > ) iterable , function , parameter , targetCollection ) ; } if ( iterable != null ) { return IterableIterate . collectWith ( iterable , function , parameter , targetCollection ) ; } throw new IllegalArgumentException ( "Cannot perform a collectWith on null" ) ; }
Same as collectWith but with a targetCollection parameter to gather the results .