(Supplier<C> factory, Supplier<T> gen, int n)
| 11 | public class Suppliers { |
| 12 | // Create a collection and fill it: |
| 13 | public static <T, C extends Collection<T>> C |
| 14 | create(Supplier<C> factory, Supplier<T> gen, int n) { |
| 15 | return Stream.generate(gen) |
| 16 | .limit(n) |
| 17 | .collect(factory, C::add, C::addAll); |
| 18 | } |
| 19 | // Fill an existing collection: |
| 20 | public static <T, C extends Collection<T>> |
| 21 | C fill(C coll, Supplier<T> gen, int n) { |