31 lines
989 B
Java
31 lines
989 B
Java
// containersindepth/TestParam.java
|
|
// ©2016 MindView LLC: see Copyright.txt
|
|
// We make no guarantees that this code is fit for any purpose.
|
|
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
|
|
// A "data transfer object."
|
|
|
|
public class TestParam {
|
|
public final int size;
|
|
public final int loops;
|
|
public TestParam(int size, int loops) {
|
|
this.size = size;
|
|
this.loops = loops;
|
|
}
|
|
// Create an array of TestParam from a varargs sequence:
|
|
public static TestParam[] array(int... values) {
|
|
int size = values.length/2;
|
|
TestParam[] result = new TestParam[size];
|
|
int n = 0;
|
|
for(int i = 0; i < size; i++)
|
|
result[i] = new TestParam(values[n++], values[n++]);
|
|
return result;
|
|
}
|
|
// Convert a String array to a TestParam array:
|
|
public static TestParam[] array(String[] values) {
|
|
int[] vals = new int[values.length];
|
|
for(int i = 0; i < vals.length; i++)
|
|
vals[i] = Integer.decode(values[i]);
|
|
return array(vals);
|
|
}
|
|
}
|