identação resolvida!
This commit is contained in:
parent
6a013de291
commit
74a0c6b88c
|
|
@ -1,76 +1,64 @@
|
|||
class Hash {
|
||||
|
||||
public class Hash {
|
||||
int tabela[];
|
||||
int m;
|
||||
int NULO = -1;
|
||||
final int NULO = -1;
|
||||
|
||||
public Hash (){
|
||||
public Hash() {
|
||||
this(13);
|
||||
}
|
||||
|
||||
public Hash (int m){
|
||||
public Hash(int m) {
|
||||
this.m = m;
|
||||
this.tabela = new int [this.m];
|
||||
for(int i = 0; i < m; i++){
|
||||
this.tabela = new int[this.m];
|
||||
for (int i = 0; i < m; i++) {
|
||||
tabela[i] = NULO;
|
||||
}
|
||||
}
|
||||
|
||||
public int h(int elemento){
|
||||
public int h(int elemento) {
|
||||
return elemento % m;
|
||||
}
|
||||
|
||||
public int reh(int elemento){
|
||||
public int reh(int elemento) {
|
||||
return ++elemento % m;
|
||||
}
|
||||
|
||||
public boolean inserir (int elemento){
|
||||
public boolean inserir(int elemento) {
|
||||
boolean resp = false;
|
||||
|
||||
if(elemento != NULO){
|
||||
|
||||
if (elemento != NULO) {
|
||||
int pos = h(elemento);
|
||||
|
||||
if(tabela[pos] == NULO){
|
||||
if (tabela[pos] == NULO) {
|
||||
tabela[pos] = elemento;
|
||||
resp = true;
|
||||
|
||||
} else{
|
||||
|
||||
} else {
|
||||
pos = reh(elemento);
|
||||
|
||||
if(tabela[pos] == NULO){
|
||||
if (tabela[pos] == NULO) {
|
||||
tabela[pos] = elemento;
|
||||
resp = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
||||
public boolean pesquisar (int elemento){
|
||||
public boolean pesquisar(int elemento) {
|
||||
boolean resp = false;
|
||||
|
||||
int pos = h(elemento);
|
||||
|
||||
if(tabela[pos] == elemento){
|
||||
if (tabela[pos] == elemento) {
|
||||
resp = true;
|
||||
|
||||
} else {
|
||||
} else if (tabela[pos] != NULO) {
|
||||
pos = reh(elemento);
|
||||
|
||||
if(tabela[pos] == elemento){
|
||||
if (tabela[pos] == elemento) {
|
||||
resp = true;
|
||||
}
|
||||
}
|
||||
return resp;
|
||||
}
|
||||
|
||||
boolean remover (int elemento){
|
||||
boolean remover(int elemento) {
|
||||
boolean resp = false;
|
||||
|
||||
//...
|
||||
|
||||
// ...
|
||||
return resp;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,60 +1,52 @@
|
|||
|
||||
public class Hash {
|
||||
int tabela[];
|
||||
int m1, m2, m, reserva;
|
||||
int NULO = -1;
|
||||
final int NULO = -1;
|
||||
|
||||
public Hash (){
|
||||
public Hash() {
|
||||
this(13, 7);
|
||||
}
|
||||
|
||||
public Hash (int m1, int m2){
|
||||
public Hash(int m1, int m2) {
|
||||
this.m1 = m1;
|
||||
this.m2 = m2;
|
||||
this.m2 = m2;
|
||||
this.m = m1 + m2;
|
||||
this.tabela = new int [this.m];
|
||||
for(int i = 0; i < m1; i++){
|
||||
this.tabela = new int[this.m];
|
||||
for (int i = 0; i < m1; i++) {
|
||||
tabela[i] = NULO;
|
||||
}
|
||||
reserva = 0;
|
||||
}
|
||||
|
||||
public int h(int elemento){
|
||||
public int h(int elemento) {
|
||||
return elemento % m1;
|
||||
}
|
||||
|
||||
public boolean inserir (int elemento){
|
||||
public boolean inserir(int elemento) {
|
||||
boolean resp = false;
|
||||
|
||||
if(elemento != NULO){
|
||||
|
||||
if (elemento != NULO) {
|
||||
int pos = h(elemento);
|
||||
|
||||
if(tabela[pos] == NULO){
|
||||
if (tabela[pos] == NULO) {
|
||||
tabela[pos] = elemento;
|
||||
resp = true;
|
||||
|
||||
} else if (reserva < m2){
|
||||
} else if (reserva < m2) {
|
||||
tabela[m1 + reserva] = elemento;
|
||||
reserva++;
|
||||
resp = true;
|
||||
}
|
||||
}
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
||||
|
||||
public boolean pesquisar (int elemento){
|
||||
public boolean pesquisar(int elemento) {
|
||||
boolean resp = false;
|
||||
|
||||
int pos = h(elemento);
|
||||
|
||||
if(tabela[pos] == elemento){
|
||||
if (tabela[pos] == elemento) {
|
||||
resp = true;
|
||||
|
||||
} else {
|
||||
for(int i = 0; i < reserva; i++){
|
||||
if(tabela[m1 + i] == elemento){
|
||||
} else if (tabela[pos] != NULO) {
|
||||
for (int i = 0; i < reserva; i++) {
|
||||
if (tabela[m1 + i] == elemento) {
|
||||
resp = true;
|
||||
i = reserva;
|
||||
}
|
||||
|
|
@ -63,11 +55,9 @@ public class Hash {
|
|||
return resp;
|
||||
}
|
||||
|
||||
boolean remover (int elemento){
|
||||
boolean remover(int elemento) {
|
||||
boolean resp = false;
|
||||
|
||||
//...
|
||||
|
||||
// ...
|
||||
return resp;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,35 +3,35 @@ class HashIndiretoLista {
|
|||
int tamanho;
|
||||
final int NULO = -1;
|
||||
|
||||
public HashIndiretoLista (){
|
||||
public HashIndiretoLista() {
|
||||
this(7);
|
||||
}
|
||||
|
||||
public HashIndiretoLista (int tamanho){
|
||||
public HashIndiretoLista(int tamanho) {
|
||||
this.tamanho = tamanho;
|
||||
tabela = new Lista[tamanho];
|
||||
for(int i = 0; i < tamanho; i++){
|
||||
for (int i = 0; i < tamanho; i++) {
|
||||
tabela[i] = new Lista();
|
||||
}
|
||||
}
|
||||
|
||||
public int h(int elemento){
|
||||
public int h(int elemento) {
|
||||
return elemento % tamanho;
|
||||
}
|
||||
|
||||
boolean pesquisar(int elemento){
|
||||
boolean pesquisar(int elemento) {
|
||||
int pos = h(elemento);
|
||||
return tabela[pos].pesquisar(elemento);
|
||||
}
|
||||
|
||||
public void inserirInicio (int elemento){
|
||||
public void inserirInicio(int elemento) {
|
||||
int pos = h(elemento);
|
||||
tabela[pos].inserirInicio(elemento);
|
||||
}
|
||||
/*
|
||||
void remover(int elemento){
|
||||
|
||||
public int remover(int elemento) {
|
||||
int resp = NULO;
|
||||
if (pesquisar(elemento) == false){
|
||||
if (pesquisar(elemento) == false) {
|
||||
throw new Exception("Erro ao remover!");
|
||||
} else {
|
||||
int pos = h(elemento);
|
||||
|
|
@ -39,5 +39,4 @@ class HashIndiretoLista {
|
|||
}
|
||||
return resp;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
|
|
|||
|
|
@ -166,6 +166,7 @@ class Serie {
|
|||
//System.out.println(resp);
|
||||
return resp;
|
||||
}
|
||||
|
||||
//método para tratar o nome do arquivo e retornar o nome da série
|
||||
public String searchName(String fileName){
|
||||
String resp = "";
|
||||
|
|
@ -178,6 +179,7 @@ class Serie {
|
|||
}
|
||||
return resp.substring(0, resp.length()-5); //retorno da substring resp retirando os 5 últimos caracteres relacionados à extensão do arquivo
|
||||
}
|
||||
|
||||
//método para leitura do arquivo .html e tratamento das linhas
|
||||
public void readClass(String fileName){
|
||||
String line;
|
||||
|
|
|
|||
Loading…
Reference in New Issue