Beispiel #1
0
        public Node[] Dividir()
        {
            if (Llaves.Count <= 2)
            {
                //No se puede dividir en 2 nodos por que aun hay espacio
            }

            Node Derechonuevo = new Node(Llaves[1]);

            for (int x = 2; x < Hijos.Count; x++) //Agrega los nodos a el nuevo nodo
            {
                Derechonuevo.Hijos.Add(this.Hijos[x]);
            }

            for (int x = Hijos.Count - 1; x >= 2; x--) //Elimina el nodo anterior
            {
                this.Hijos.RemoveAt(x);
            }

            for (int x = 1; x < Llaves.Count; x++)
            {
                Llaves.RemoveAt(x);
            }

            return(new Node[] { this, Derechonuevo });
        }
Beispiel #2
0
        public Nodo[] Split()
        {
            if (Llaves.Count != 2)
            {
                throw new InvalidOperationException(string.Format("This node has {0} Llaves, can only split a 2 Llaves node", Llaves.Count));
            }


            //TO DO: Hacer que nodo derecho obtenga todas la llaves a la derecha

            //Nodo derecho
            Nodo newRight = new Nodo(Llaves[1]);

            //inicia en la mitad y recorre valores hasta el final
            for (int x = 2; x < Hijos.Count; x++)
            {
                newRight.Hijos.Add(this.Hijos[x]);
            }


            //Remover valores presentes en nodo derecho
            for (int x = Hijos.Count - 1; x >= 2; x--)
            {
                this.Hijos.RemoveAt(x);
            }

            for (int x = 1; x < Llaves.Count; x++)
            {
                Llaves.RemoveAt(x);
            }

            //retorna vector con nodo izquierdo y derecho
            return(new Nodo[] { this, newRight });
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
        public ActionResult GenerarLlaves(string p, string q)
        {
            if (int.TryParse(p, out int NumeroP) && int.TryParse(q, out int NumeroQ))
            {
                if (NumerosPrimos.esNumeroPrimo(NumeroP) && NumerosPrimos.esNumeroPrimo(NumeroQ))
                {
                    if (NumeroP * NumeroQ >= 256)
                    {
                        Llaves.GenerarLlaves(NumeroP, NumeroQ);

                        return(DownloadKeys());
                    }
                    else
                    {
                        ViewBag.Message = "P y Q deben ser numeros mayores";
                    }
                }
                else
                {
                    ViewBag.Message = "P y Q deben ser numeros primos";
                }
            }
            else
            {
                ViewBag.Message = "Entrada no valida";
            }

            return(View());
        }
Beispiel #5
0
        public ActionResult DeleteConfirmed(int id)
        {
            Llaves llaves = db.Llaves.Find(id);

            db.Llaves.Remove(llaves);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Beispiel #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            usuario       = new Usuarios();
            llavePublica1 = new Llaves();
            llavePublica2 = new Llaves();
            certificador1 = new Llaves();
            certificador2 = new Llaves();

            operaciones = new Operaciones();
        }
Beispiel #7
0
 public ActionResult Edit([Bind(Include = "ID,IdSitio,NombreSitio,OTFG,QuienRetira,Empresa,Celular,Fecha,Hora,OperadorEntrega,LlaveMecanica,LlaveAcsys,FechaRetorno,HoraRetorno,OperadorRecibe,Comentarios")] Llaves llaves)
 {
     if (ModelState.IsValid)
     {
         db.Entry(llaves).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(llaves));
 }
Beispiel #8
0
 public void Push(Medicamento valor)
 {
     if (Llaves.Count == 0)
     {
         Llaves.Add(valor);
     }
     else
     {
         Llaves.Add(valor);
         Llaves.Sort(compararmedicamentos);
     }
 }
Beispiel #9
0
        public Medicamento Pop(int posicion)
        {
            if (posicion < Llaves.Count)
            {
                Medicamento valor = Llaves[posicion];
                Llaves.RemoveAt(posicion);

                return(valor);
            }

            return(null);
        }
Beispiel #10
0
        public string Remover(int pos)
        {
            if (Llaves.Count > 1)//Solo se puede si hay mas de una llave, si no se quedaria vacio
            {
                if (pos < Llaves.Count)
                {
                    string temp = Llaves[pos];
                    Llaves.RemoveAt(pos);
                    return(temp);
                }
            }

            return(null);
        }
Beispiel #11
0
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Llaves llaves = db.Llaves.Find(id);

            if (llaves == null)
            {
                return(HttpNotFound());
            }
            return(View(llaves));
        }
Beispiel #12
0
 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);
     }
 }
Beispiel #13
0
        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);
        }
Beispiel #14
0
        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);
            }
        }
Beispiel #15
0
        /// <summary>
        /// Retorna un valor de la sección appSettings.
        /// </summary>
        /// <param name="nombreLlave"></param>
        /// <returns></returns>
        static string ObtenerValorLlave(string nombreLlave)
        {
            if (string.IsNullOrWhiteSpace(nombreLlave))
            {
                return(null);
            }

            var LlaveMinusc = nombreLlave.ToLower();

            if (Llaves == null)
            {
                return(null);
            }
            else if (Llaves.ContainsKey(LlaveMinusc))
            {
                return(Llaves[LlaveMinusc]);
            }
            else
            {
                return(null);
            }
        }
Beispiel #16
0
 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);
     }
 }
Beispiel #17
0
 public long ObtenApuntadorHoja(int dato)
 {
     return(DireccionLlaves[Llaves.IndexOf(dato)]);
 }