I'm trying to use different lists & sets and test the needed time. The method should be flexible enough to test other possible classes. Currently I'm able to use the List-classes but with the HashSet
I get an error.
Anybody know how to use the test-class with HashSet and
LinkedList`?
ArrayList<String> arrList = new ArrayList<String>();
LinkedList linklist = new LinkedList();
HashSet<String> hash = new HashSet<String>();
test(arrList);
test(linklist);
test(hash);
private static <T> void test(List<String> t) {
start = System.nanoTime();
for(int i=0; i < 1000; i++) {
t.add(r);
time = System.nanoTime() - start;
}
System.out.println("Add: " + time);
}