internal void SepararNodo(string llave, T dato, int hijoDerecho, Nodo <T> nuevoNodo, ref string llavePorSubir, ref T datoPorSubir) { if (!Lleno) { throw new Exception("Uno nodo solo puede separarse si está lleno"); } Llaves.Add("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); Datos.Add(dato); Hijos.Add(Utilidades.apuntadoVacio); AgregarDato(llave, dato, hijoDerecho, false); int mitad = (Orden / 2); llavePorSubir = Utilidades.FormatearLlave(Llaves[mitad]); datoPorSubir = Datos[mitad]; Llaves[mitad] = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; int j = 0; for (int i = mitad + 1; i < Llaves.Count; i++) { nuevoNodo.Llaves[j] = Llaves[i]; nuevoNodo.Datos[j] = Datos[i]; Llaves[i] = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; j++; } j = 0; for (int i = mitad + 1; i < Hijos.Count; i++) { nuevoNodo.Hijos[j] = Hijos[i]; Hijos[i] = Utilidades.apuntadoVacio; j++; } Llaves.RemoveAt(Llaves.Count - 1); Datos.RemoveAt(Datos.Count - 1); Hijos.RemoveAt(Hijos.Count - 1); }
public void Push(Medicamento valor) { if (Llaves.Count == 0) { Llaves.Add(valor); } else { Llaves.Add(valor); Llaves.Sort(compararmedicamentos); } }
public bool EliminaEnNodoRaiz(int Clave, long Direccion) { if (Llaves.Contains(Clave) && DireccionLlaves.Contains(Direccion)) { DireccionLlaves.Remove(Direccion); Llaves.Remove(Clave); DireccionLlaves.Add((long)-1); Llaves.Add(-1); return(true); } else { return(false); } }
internal void SepararNodo(string llave, T dato, int hijoDerecho, NodoB <T> nuevoNodo, ref string llavePorSubir, ref T datoPorSubir) { if (!Lleno) { throw new Exception("Uno nodo solo puede separarse si está lleno"); } // Incrementar el tamaño de las listas en una posición Llaves.Add("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"); Datos.Add(dato); Hijos.Add(Utilidades.ApuntadorVacio); // Agregar los nuevos elementos en orden AgregarDato(llave, dato, hijoDerecho, false); // Obtener los valores a subir int mitad = (Orden / 2); llavePorSubir = Llaves[mitad]; datoPorSubir = Datos[mitad]; Llaves[mitad] = "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"; // Llenar las llaves y datos que pasan al nuevo nodo int j = 0; for (int i = mitad + 1; i < Llaves.Count; i++) { nuevoNodo.Llaves[j] = Llaves[i]; nuevoNodo.Datos[j] = Datos[i]; Llaves[i] = "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"; j++; } // Llenar los hijos que pasan al nuevo nodo j = 0; for (int i = mitad + 1; i < Hijos.Count; i++) { nuevoNodo.Hijos[j] = Hijos[i]; Hijos[i] = Utilidades.ApuntadorVacio; j++; } Llaves.RemoveAt(Llaves.Count - 1); Datos.RemoveAt(Datos.Count - 1); Hijos.RemoveAt(Hijos.Count - 1); }
public bool EliminaDatoEnHoja(int Clave) { if (Llaves.Contains(Clave)) { int Indice = Llaves.IndexOf(Clave); long SigNodo = DireccionLlaves[Arbol.GradoArbol - 1]; DireccionLlaves[Arbol.GradoArbol - 1] = (long)-1; Llaves.RemoveAt(Indice); DireccionLlaves.RemoveAt(Indice); Llaves.Add(-1); DireccionLlaves.Add(SigNodo); return(true); } else { return(false); } }
public void AgregarValorNodo(string temp) { if (IsEmpty(Llaves)) //Ya que esta libre solo se agrega { Llaves.Add(temp); } else { string left = " "; for (int i = 0; i < Llaves.Count; i++) { if (string.Compare(left, temp, StringComparison.CurrentCulture) < 0 && string.Compare(temp, Llaves[i], StringComparison.CurrentCulture) < 0) { Llaves.Insert(i, temp); return; } else { left = Llaves[i]; } } Llaves.Add(temp); } }