//Métodos de búsqueda public PacienteArbol BuscarNumero(string numero, ArbolAVL.Arbol <PacienteArbol> ArbolAvl) { numero.Replace(" ", ""); long dpi = Convert.ToInt64(numero); NodoAVL <PacienteArbol> recorrer = ArbolAvl.raiz; bool encontrar = false; while (recorrer != null && encontrar == false) { long valor = recorrer.valor.DPI_CUI; if (dpi == valor) { encontrar = true; } else { if (dpi > recorrer.valor.DPI_CUI) { recorrer = recorrer.derecha; encontrar = false; } else { recorrer = recorrer.izquierda; encontrar = false; } } } if (recorrer == null) { return(null); } return(recorrer.valor); }
public void InsertarValor(PacienteArbol valor, ArbolAVL.Arbol <PacienteArbol> Arbol) { NodoAVL <T> NuevoNodo = new NodoAVL <T>(); NuevoNodo.valor = valor; NuevoNodo.izquierda = null; NuevoNodo.derecha = null; if (BuscarNumero(valor.DPI_CUI.ToString(), Arbol /*valor.DPI_CUI*/) != null) { return; } if (raiz == null) { raiz = NuevoNodo; } else { raiz = InsertarNodoValor(raiz, NuevoNodo); } contador++; }
public PacienteArbol BuscarA(string nombre, ArbolAVL.Arbol <PacienteArbol> ArbolAvl) { NodoAVL <PacienteArbol> recorrer = ArbolAvl.raiz; nombre = nombre.ToLower(); nombre.Replace(" ", ""); bool encontrar = false; while (recorrer != null && encontrar == false) { string valor = recorrer.valor.Apellido.Replace(" ", ""); valor = valor.ToLower(); if (nombre == valor) { encontrar = true; } else { if (nombre.CompareTo(recorrer.valor.Apellido) > 0) { recorrer = recorrer.derecha; encontrar = false; } else { recorrer = recorrer.izquierda; encontrar = false; } } } if (recorrer == null) { return(null); } return(recorrer.valor); }
public void InsertarApellidos(PacienteArbol valor, ArbolAVL.Arbol <PacienteArbol> Arbol) { NodoAVL <T> NuevoNodo = new NodoAVL <T>(); NuevoNodo.valor = valor; NuevoNodo.izquierda = null; NuevoNodo.derecha = null; if (Buscar(valor.Apellido, Arbol) != null) { raiz = InsertarNodoNombre(raiz, NuevoNodo); contador++; return; } if (raiz == null) { raiz = NuevoNodo; } else { raiz = InsertarNodoApellido(raiz, NuevoNodo); } contador++; }
// Método del delegado public PacienteArbol RetornarValor(ArbolAVL.Arbol <PacienteArbol> ListaDatos, string dato, BuscarCampo CampoBusqueda) { return(CampoBusqueda(dato, ListaDatos)); }