public void ImprimirInvertido() { celula temp = Fim; while (temp != Inicio) { Console.WriteLine(temp.dado); temp = temp.ant; } }
public void Imprimir() { int cont = 0; celula temp = Inicio; while (cont < Tam) { Console.WriteLine(temp.dado); temp = temp.prox; cont++; } }
public void Inserir(int dado) { celula temp = new celula(); temp.dado = dado; temp.prox = Inicio; temp.ant = Fim; Fim.prox = temp; Fim = temp; Fim.prox = Inicio; Inicio.ant = Fim; Tam++; }
public void RemoverCelula(celula temp) { Tam--; celula ant = temp.ant; celula prox = temp.prox; ant.prox = prox; prox.ant = ant; if (temp == Inicio) { Inicio = temp.prox; Inicio.ant = Fim; } if (temp == Fim) { Fim = temp.ant; Fim.prox = Inicio; } }
public int Remover(int m, int o) { celula temp = Inicio; for (int i = 1; i < m; i++) { temp = temp.prox; } while (Tam > 1) { for (int j = 0; j < o; j++) { temp = temp.prox; } RemoverCelula(temp); } Imprimir(); return(temp.dado); }
public lista(int n) { celula temp = new celula(); temp.dado = 1; temp.ant = temp.prox = null; Tam = 1; Inicio = Fim = temp; while (Tam < n) { Tam++; temp = new celula(); temp.dado = Tam; temp.prox = null; temp.ant = Fim; Fim.prox = temp; Fim = temp; } Fim.prox = Inicio; Inicio.ant = Fim; }