2008-06-09 18:41:06 +00:00
|
|
|
|
|
|
|
package net.sourceforge.tuned;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Collection;
|
|
|
|
import java.util.Collections;
|
2008-06-21 23:31:19 +00:00
|
|
|
import java.util.Iterator;
|
2008-06-09 18:41:06 +00:00
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
|
public class TestUtil {
|
|
|
|
|
2008-06-29 17:38:57 +00:00
|
|
|
public static List<Object[]> asParameters(Object... parameterSet) {
|
|
|
|
List<Object[]> list = new ArrayList<Object[]>();
|
2008-06-09 18:41:06 +00:00
|
|
|
|
2008-06-29 17:38:57 +00:00
|
|
|
for (Object parameter : parameterSet) {
|
|
|
|
list.add(new Object[] { parameter });
|
2008-06-09 18:41:06 +00:00
|
|
|
}
|
|
|
|
|
2008-06-29 17:38:57 +00:00
|
|
|
return list;
|
2008-06-09 18:41:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-06-21 23:31:19 +00:00
|
|
|
public static <T> List<T> asList(Iterator<T> iterator) {
|
|
|
|
List<T> list = new ArrayList<T>();
|
|
|
|
|
|
|
|
while (iterator.hasNext()) {
|
|
|
|
list.add(iterator.next());
|
|
|
|
}
|
|
|
|
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-06-29 17:38:57 +00:00
|
|
|
public static <T> List<List<T>> rotations(Collection<T> source) {
|
|
|
|
List<List<T>> rotations = new ArrayList<List<T>>();
|
2008-06-09 18:41:06 +00:00
|
|
|
|
2008-06-29 17:38:57 +00:00
|
|
|
for (int i = 0; i < source.size(); i++) {
|
|
|
|
List<T> copy = new ArrayList<T>(source);
|
|
|
|
Collections.rotate(copy, i);
|
|
|
|
rotations.add(copy);
|
2008-06-09 18:41:06 +00:00
|
|
|
}
|
|
|
|
|
2008-06-29 17:38:57 +00:00
|
|
|
return rotations;
|
2008-06-09 18:41:06 +00:00
|
|
|
}
|
2008-06-29 17:38:57 +00:00
|
|
|
|
2008-06-09 18:41:06 +00:00
|
|
|
}
|