OnJava8-Examples/com/mindviewinc/util/CollectionData.java
Bruce Eckel 49edcc8b17 reorg
2015-06-15 17:47:35 -07:00

18 lines
547 B
Java

//: com/mindviewinc/util/CollectionData.java
// ©2015 MindView LLC: see Copyright.txt
// A Collection filled with data using a generator object.
package com.mindviewinc.util;
import java.util.*;
public class CollectionData<T> extends ArrayList<T> {
public CollectionData(Generator<T> gen, int quantity) {
for(int i = 0; i < quantity; i++)
add(gen.next());
}
// A generic convenience method:
public static <T> CollectionData<T>
list(Generator<T> gen, int quantity) {
return new CollectionData<>(gen, quantity);
}
} ///:~