Commit 12ad8793 by Patryk Czarnik

bez new

parent 1e457c41
......@@ -8,7 +8,7 @@ public class PorownanieSzybkosciList {
public static void testujListe(List<Integer> lista) {
long start, koniec;
int suma;
System.out.print("Wstawianie 250 tys. na koniec listy (add)... ");
start = System.currentTimeMillis();
for(int i=0; i<250000; i++) {
......@@ -16,9 +16,9 @@ public class PorownanieSzybkosciList {
}
koniec = System.currentTimeMillis();
System.out.println(koniec - start + " ms");
lista.clear(); // usuwa całą zawartość
System.out.print("Wstawianie 500 tys. na koniec listy (add)... ");
start = System.currentTimeMillis();
for(int i=0; i<500000; i++) {
......@@ -26,16 +26,17 @@ public class PorownanieSzybkosciList {
}
koniec = System.currentTimeMillis();
System.out.println(koniec - start + " ms");
System.out.println("\nDodawanie na początek... ");
start = System.currentTimeMillis();
Integer nowyElement = 333;
for(int i=0; i < 10000; i++) {
lista.add(0, 333); // 333 jest elementem (wartością) a nie indeksem
lista.add(0, nowyElement);
// Szybko dla LinkedList, wolno dla ArrayList
}
koniec = System.currentTimeMillis();
System.out.println(koniec - start + " ms");
System.out.println("\nWybieranie po indeksie... ");
start = System.currentTimeMillis();
suma = 0;
......@@ -46,7 +47,7 @@ public class PorownanieSzybkosciList {
koniec = System.currentTimeMillis();
System.out.println(koniec - start + " ms");
System.out.println("wynik="+suma);
System.out.println("\nOdczytanie wszystkich elementów foreach");
start = System.currentTimeMillis();
suma = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment