12.07.2015 Views

k19-k11-orientacao-a.. - Departamento de Sistemas e Computação

k19-k11-orientacao-a.. - Departamento de Sistemas e Computação

k19-k11-orientacao-a.. - Departamento de Sistemas e Computação

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

COLLECTIONS 15613 tempo = TestaAdicionaNoComeco . adicionaNoComeco ( linkedList );14 System . out . println (" LinkedList : " + tempo + "ms");1516 }1718 public static long adicionaNoComeco ( List lista ) {19 long inicio = System . currentTimeMillis ();2021 int size = 100000;2223 for ( int i = 0; i < size ; i ++) {24 lista . add (0, i);25 }2627 long fim = System . currentTimeMillis ();2829 return fim - inicio ;30 }31 }Código Java 18.17: TestaAdicionaNoComeco.java1 import java . util . ArrayList ;2 import java . util . LinkedList ;3 import java . util . List ;45 public class TestaGet {6 public static void main ( String [] args ) {7 ArrayList arrayList = new ArrayList ();8 LinkedList linkedList = new LinkedList ();910 long tempo = TestaGet . get ( arrayList );11 System . out . println (" ArrayList : " + tempo + "ms");1213 tempo = TestaGet . get ( linkedList );14 System . out . println (" LinkedList : " + tempo + "ms");1516 }1718 public static long get ( List lista ) {1920 int size = 100000;2122 for ( int i = 0; i < size ; i ++) {23 lista . add (i);24 }2526 long inicio = System . currentTimeMillis ();2728 for ( int i = 0; i < size ; i ++) {29 lista . get (i);30 }3132 long fim = System . currentTimeMillis ();3334 return fim - inicio ;35 }36 }Código Java 18.18: TestaGet.java3 Teste o <strong>de</strong>sempenho para remover elementos do começo ou do fim das listas.Conjuntos156 www.<strong>k19</strong>.com.br

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!