public T Eliminar(int i) { try { NodoL <T> x; if (i == 0) { x = this.Cabeza.GetSig(); this.Cabeza.SetSig(x.GetSig()); this.Cabeza.GetSig().SetAnt(this.Cabeza); x.SetSig(null); x.SetAnt(null); this.Tamanio--; return(x.GetInfo()); } x = this.GetPos(i - 1); if (x == null) { return(default(T)); } NodoL <T> y = x.GetSig(); x.SetSig(y.GetSig()); y.GetSig().SetAnt(x); y.SetSig(null); y.SetAnt(null); this.Tamanio--; return(y.GetInfo()); } catch (Exception ex) { throw ex; } return(default(T)); }
public T Eliminar(T pDato) { NodoL <T> temp = this.Cabeza, anterior = this.Cabeza; int longit = this.GetTamanio(); int rta; for (int i = 0; i < this.GetTamanio(); i++) { rta = Comparable.GetInstancia().Compare(Cabeza.GetInfo(), pDato); if (rta == 0 && i == 0) { this.Cabeza = temp.GetSig(); longit = longit - 1; this.Tamanio = longit; } rta = Comparable.GetInstancia().Compare(temp.GetInfo(), pDato); if (rta == 0 && i > 0) { anterior.SetSig(temp.GetSig()); longit = longit - 1; this.Tamanio = longit; } anterior = temp; temp = temp.GetSig(); } return(default(T)); }
public bool EnColar(NodoL <T> pNodo) { bool result = false; NodoL <T> aux; pNodo.SetSig(null); if (this.EsVacia() || this.Tamanio == 0) { this.Inicio = pNodo; result = true; } else { aux = this.Inicio; bool bandera = true; while (bandera) { if (aux.GetSig() == null) { aux.SetSig(pNodo); result = true; bandera = false; } aux = aux.GetSig(); } } int longt = this.GetTamanio(); longt = longt + 1; this.Tamanio = longt; return(result); }
public bool InsertarAlInicio(NodoL <T> pNodo) { bool result = false; if (this.EsVacia()) { pNodo.SetSig(null); this.Cabeza = pNodo; result = true; } else { pNodo.SetSig(this.Cabeza); this.Cabeza = pNodo; result = true; } int longt = this.GetTamanio(); longt = longt + 1; this.Tamanio = longt; return(result); }
public bool InsertarOrdenado(T pDato) { bool result = false; NodoL <T> newNode = new NodoL <T>(pDato, null); if (this.EsVacia()) { this.Cabeza = newNode; result = true; } else { NodoL <T> temp = Cabeza; int rta = Comparable.GetInstancia().Compare(Cabeza.GetInfo(), pDato); if (rta == 1) { newNode.SetSig(Cabeza); this.Cabeza = newNode; result = true; } else { while ((temp.GetSig() != null) && (Comparable.GetInstancia().Compare(temp.GetSig().GetInfo(), pDato) < 0)) { temp = temp.GetSig(); } newNode.SetSig(temp.GetSig()); temp.SetSig(newNode); result = true; } } int longt = this.GetTamanio(); longt = longt + 1; this.Tamanio = longt; return(result); }
private bool Enlazar(NodoL <T> cabeza, Lista <T> lista) { bool result = false; if (cabeza.GetSig() is null) { cabeza.SetSig(lista.GetCabeza()); result = true; } else { result = Enlazar(cabeza.GetSig(), lista); } return(result); }
public T DeColar() { if (this.EsVacia()) { return(default(T)); } NodoL <T> x = this.Inicio.GetSig(); this.Inicio.SetSig(x.GetSig()); x.GetSig().SetAnt(Inicio); x.SetSig(null); x.SetAnt(null); this.Tamanio--; return(x.GetInfo()); }
public void Apilar(NodoL <T> pNodo) { if (this.EsVacia()) { this.Tope = pNodo; } else { pNodo.SetSig(this.Tope); this.Tope = pNodo; } int longt = this.GetTamanio(); longt = longt + 1; this.Tamanio = longt; }
public bool InsertarAlFinal(T pDato) { bool result = false; NodoL <T> newNode = new NodoL <T>(pDato), aux; newNode.SetSig(null); if (this.EsVacia()) { this.Cabeza = newNode; result = true; } else { int rta = Comparable.GetInstancia().Compare(this.Cabeza.GetInfo(), 0); if (rta == 0 && this.Cabeza.GetSig() == null && this.Tamanio == 0) { this.Cabeza = newNode; result = true; } else { aux = this.Cabeza; bool bandera = true; while (bandera) { if (aux.GetSig() == null) { aux.SetSig(newNode); result = true; bandera = false; } aux = aux.GetSig(); } } } int longt = this.GetTamanio(); longt = longt + 1; this.Tamanio = longt; return(result); }
public bool InsertarAlInicio(T pDato) { bool result = false; NodoL <T> newNode = new NodoL <T>(pDato); if (this.EsVacia()) { this.Cabeza = newNode; result = true; } else { newNode.SetSig(this.Cabeza); this.Cabeza = newNode; result = true; } int longt = this.GetTamanio(); longt = longt + 1; this.Tamanio = longt; return(result); }