public string[] String() { Elemento aux = this.atual.Anterior; string[] texto = new string[this.count]; int cont = 0; try { if (this.Vazia()) { throw null; } else { while (aux.DadoProcesso() != null) { texto[cont] = aux.DadoProcesso().ToString(); aux = aux.Anterior; cont++; } return(texto); } } catch (System.Exception e) { MessageBox.Show("Erro na Lista Encadeada (ToString). {0} \n", e.ToString(), MessageBoxButtons.OK); return(texto); } }
// Método Retirar() sempre pega o primeiro elemento. public Processo Retirar() { try { if (this.Vazia()) { return(null); } Elemento aux = new Elemento(this.atual.Anterior); this.atual.Anterior = this.atual.Anterior.Anterior; if (this.Vazia()) { this.atual.Proximo = this.atual; } this.count = this.count - 1; return(aux.DadoProcesso()); } catch (System.Exception e) { MessageBox.Show("Erro na Lista Circular (Retirar). {0} \n", e.ToString(), MessageBoxButtons.OK); throw; } }
public Processo BuscaRetira(Processo processo) { try { Elemento aux = this.Busca(new Elemento(processo)); Elemento auxRetirada = new Elemento(); if (aux == null) { } if (aux.Proximo != null) { auxRetirada = aux.Proximo; aux.Proximo = aux.Proximo.Proximo; if (aux.Proximo == null) { this.ultimo = aux; } this.count = this.count - 1; return(auxRetirada.DadoProcesso()); } } catch (System.Exception e) { MessageBox.Show("Erro na Lista Encadeada (BuscaRetira). {0} \n", e.ToString(), MessageBoxButtons.OK); throw; } return(null); }
public Processo RetiraPrimeiro() { try { Elemento auxretirada = new Elemento(); if (this.Vazia() == true) { return(null); } else { auxretirada = this.primeiro.Proximo; this.primeiro.Proximo = auxretirada.Proximo; if (this.primeiro.Proximo == null) { this.ultimo = this.primeiro; } this.count = this.count - 1; return(auxretirada.DadoProcesso()); } } catch (System.Exception e) { MessageBox.Show("Erro na Lista Encadeada (RetiraPrimeiro). {0} \n", e.ToString(), MessageBoxButtons.OK); throw; } }
public override string ToString() { try { Elemento aux = this.primeiro.Proximo; string texto = null; if (this.Vazia()) { return(null); } else { do { texto = texto + string.Format(aux.DadoProcesso().ToString() + "{0}", Environment.NewLine); //texto = texto + aux.DadoProcesso().ToString() + "\n"; aux = aux.Proximo; } while (aux != null); return(texto); } } catch (System.Exception e) { MessageBox.Show("Erro na Lista Encadeada (ToString). {0} \n", e.ToString(), MessageBoxButtons.OK); return(""); } }
private Elemento Busca(Elemento elemento) { try { if (this.Vazia()) { return(null); } Elemento percorre = this.primeiro; while (percorre.Proximo != null) {// IF está funcionando como um método equals**** if (percorre.Proximo.DadoProcesso().Id == elemento.DadoProcesso().Id) { return(percorre); } percorre = percorre.Proximo; } return(null); } catch (System.Exception e) { MessageBox.Show("Erro na Lista Encadeada (Busca). {0} \n", e.ToString(), MessageBoxButtons.OK); throw; } }
public Processo Busca(Processo busca) { Elemento aux = this.atual.Anterior; try { while (aux != null) { if (aux.DadoProcesso().Id == busca.Id) { return(aux.DadoProcesso()); } aux = aux.Anterior; } return(null); } catch { return(null); } }
public Elemento(Elemento elemento) { this.anterior = elemento.Anterior; this.processo = elemento.DadoProcesso(); this.proximo = elemento.Proximo; }