-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTabelaHash.java
37 lines (29 loc) · 899 Bytes
/
TabelaHash.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
import java.util.HashSet;
import java.util.Set;
public class TabelaHash {
private String[] tabela;
private Set<Integer> chaves;
private Set<String> valores;
private int size;
public static final double FATOR_DE_CARGA_DEFAULT = 0.75;
public static final int CAPACIDADE_DEFAULT = 7; // usar sempre um número primo
public static final String flag = new String("apagado");
public TabelaHash() {
this.tabela = new String[CAPACIDADE_DEFAULT];
this.chaves = new HashSet<Integer>();
this.valores = new HashSet<String>();
this.size = 0;
}
public int size() {
return this.size;
}
private int hash(Integer chave) {
return chave % this.tabela.length;
}
public Set<Integer> getKeys() {
return this.chaves;
}
public Set<String> getValues() {
return this.valores;
}
}