+ 1
Changing Collection Big O
I had a ideia but I don't know how right test. If some List have better "get" and other have better "remove"... How can I test if works if I change list to better. Example: ArrayList<Integer> list = new ArrayList<>(); list.addAll([1,2,3,4,5]). Now, I'm working "list.get(index)" cause is better BigO, but then when I wanna remove: LinkedList<Integer> linked = new LinkedList<>(list); //better remove on Big O linked.remove(2); linked.remove(4); list = new ArrayList<>(linked); // bacing ArrayList that have better get index on BiG O... So, changing List to use best Big O. Worth or it? (Cause casting will consume memory too, I know, but how much comparing?).
1 Odpowiedź
+ 1
long startTime, endTime;
startTime = System.currentTimeMillis();
//do something
endTime = System.currentTimeMillis()
System.out.println(endTime - startTime);
run more than one for more accurate result