Bruce Eckel 49edcc8b17 reorg
2015-06-15 17:47:35 -07:00

19 lines
564 B
Java

//: com/mindviewinc/util/Generated.java
// ©2015 MindView LLC: see Copyright.txt
package com.mindviewinc.util;
public class Generated {
// Fill an existing array:
public static <T> T[] array(T[] a, Generator<T> gen) {
return new CollectionData<>(gen, a.length).toArray(a);
}
// Create a new array:
@SuppressWarnings("unchecked")
public static <T> T[] array(Class<T> type,
Generator<T> gen, int size) {
T[] a =
(T[])java.lang.reflect.Array.newInstance(type, size);
return new CollectionData<>(gen, size).toArray(a);
}
} ///:~