-
Notifications
You must be signed in to change notification settings - Fork 0
/
MetodosRemover.java
55 lines (49 loc) · 1.72 KB
/
MetodosRemover.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import java.io.FileWriter;
import java.io.IOException;
import java.util.AbstractList;
import java.util.Map;
import java.util.Set;
public class MetodosRemover {
public static String[] nomesRemover = {"Lisbon", "NASA", "Kyunghee",
"Konkuk", "Sogang", "momentarily", "rubella", "vaccinations",
"government", "Authorities"};
public static void escreverEstatisticas(Long tempo) {
try (FileWriter writer = new FileWriter("tempo.txt",true)) {
writer.write(tempo + " ");
writer.close();
}
catch(IOException e) {
System.out.println("Erro");
}
}
public static void remover(AbstractList<String> list) {
long inicio = System.nanoTime();
for (String s : nomesRemover) {
list.remove(s);
}
long fim = System.nanoTime();
long tempoDeExecucao = fim - inicio;
System.out.println(tempoDeExecucao);
escreverEstatisticas(tempoDeExecucao);
}
public static void remover(Set<String> set) {
long inicio = System.nanoTime();
for (String s : nomesRemover) {
set.remove(s);
}
long fim = System.nanoTime();
long tempoDeExecucao = fim - inicio;
System.out.println(tempoDeExecucao);
escreverEstatisticas(tempoDeExecucao);
}
public static void remover(Map<String,Integer> map) {
long inicio = System.nanoTime();
for (String s : nomesRemover) {
map.remove(s);
}
long fim = System.nanoTime();
long tempoDeExecucao = fim - inicio;
System.out.println(tempoDeExecucao);
escreverEstatisticas(tempoDeExecucao);
}
}