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