コード例 #1
0
ファイル: CNodo.cs プロジェクト: miguellgt/file-structures
        /**\brief Inseta una clave en el nodo en forma ordenada*/
        public void insClaveOrd(Object clave, CBloque bloque, CArchivo file, int posClave)
        {
            //Movimiento de claves, dirClaves y dirNodos
            for (int i = getNumElemnt(); i > posClave; i--)
            {
                claves[i] = claves[i - 1];
                dirClaves[i] = dirClaves[i - 1];
                
                if (getTipoNodo() == 1 || getTipoNodo() == 4)//Si la clave a insertar es diferente a una hoja
                    dirNodos[i+1] = dirNodos[i];
                else
                    dirNodos[i] = dirNodos[i - 1];
            }

            if (getTipoNodo() == 2 || getTipoNodo() == 3)//La clave se va a insertar en una hoja o en la raizHoja
            {
                dirNodos[posClave] = file.ENDF();
                file.EscribeBloque(bloque, file.ENDF());
            }

            claves[posClave] = clave;
            incNumElem();

            if (getTipoNodo() == 2 || getTipoNodo() == 3)//Si la clave a insertar es diferente a una raiz o pagima
            {
                dirClaves[posClave] = file.ENDF();
                escribeClave(clave, file.ENDF(), bloque.getTipoCA(), file);
            }
        }
コード例 #2
0
ファイル: FormOrg.cs プロジェクト: miguellgt/file-structures
        /**Función de Mantenimiento para la Hash Dinamica*/
        private void MantenimientoHashDinamica(CArchivo fileOri, CArchivo fileNew, CNodoEntidad ent, CNodoEntidad entC, int tamBloque)
        {
            CTablaHashExt tH, nuevaTH;
            List<CCubeta> listCub;
            List<int> lE;
            CCubeta nuevaCub;
            long cabDatos;

            cabDatos = ent.getApCabDatos();

            if (cabDatos != -1)
            {
                tH = fileOri.LeerTablaHashExt(cabDatos);
                nuevaTH = creaTabla(tH);

                listCub = dameCubetas(tH);
                foreach (CCubeta c in listCub)
                {
                    lE = buscaEntradas(tH, c);
                    nuevaCub = creaCubeta(c, fileNew, fileOri);

                    foreach (int i in lE)
                        nuevaTH.getAtEntrada(i).setCubeta(nuevaCub);
                }

                foreach (CEntrada e in nuevaTH.getListEntradas())
                {
                    e.setDir(fileNew.ENDF());
                    fileNew.EscribeEntrada(e);
                }

                for (int i = 0; i < nuevaTH.getListEntradas().Count - 1; i++)
                {
                    nuevaTH.getAtEntrada(i).setSigEntrada(nuevaTH.getAtEntrada(i + 1).getDir());
                    fileNew.EscribeEntrada(nuevaTH.getAtEntrada(i));
                }

                nuevaTH.setCabEntradas(nuevaTH.getAtEntrada(0).getDir());
                nuevaTH.setDir(fileNew.ENDF());
                fileNew.EscribeTablaHashExt(nuevaTH);
                entC.setApCabDatos(nuevaTH.getDir());
                fileNew.escribeEntidad(entC,entC.getDir());
            }
        }
コード例 #3
0
ファイル: FormOrg.cs プロジェクト: miguellgt/file-structures
        private CCubeta creaCubeta(CCubeta c, CArchivo aN, CArchivo aO)
        {
            CCubeta nuevaCub;
            CBloque bloqAux;

            nuevaCub = new CCubeta(aN.ENDF(), c.getTamaño());

            nuevaCub.setNumDirBloques(c.getNumDirBloques());
            nuevaCub.setPrefAsoc(c.getPrefAsoc());

            for (int i = 0; i < c.getTamaño(); i++)
                if ((bloqAux = aO.leerBloque(c.getAtDirBloque(i), tamBloque)) != null)
                {
                    bloqAux.setTamBlo(tamBloque);
                    nuevaCub.setAtDirBloque(i, aN.ENDF());
                    aN.EscribeBloque(bloqAux, aN.ENDF());
                }

            nuevaCub.setDir(aN.ENDF());
            aN.EscribeCubeta(nuevaCub);

            return (nuevaCub);
        }
コード例 #4
0
ファイル: FormOrg.cs プロジェクト: miguellgt/file-structures
        /**Función de Mantenimiento para la Hash Estatica*/
        private void MantenimientoHashEstatica(CArchivo fileOri, CArchivo fileNew, CNodoEntidad ent, CNodoEntidad entC, int tamBloque)
        {
            CHash tablaHash, nuevaTablaHash;
            long cabTabla;

            cabTabla = ent.getApCabDatos();

            if (cabTabla != -1)
            {
                tablaHash = fileOri.LeerTablaHash(cabTabla);
                nuevaTablaHash = new CHash(fileNew.ENDF(), tablaHash.getTamaño());
                nuevaTablaHash.setNumCubetas(tablaHash.getNumCubetas());

                fileNew.EscribeTablaHash(nuevaTablaHash);

                for (int i = 0; i < tablaHash.getTamaño(); i++)
                    nuevaTablaHash.setAtDirCubeta(i, CopiarListaCubetasRec(tablaHash.getAtDirCubeta(i), fileOri, fileNew, tamBloque));

                fileNew.EscribeTablaHash(nuevaTablaHash);

                entC.setApCabDatos(nuevaTablaHash.getDir());
                fileNew.escribeEntidad(entC, entC.getDir());
            }
        }
コード例 #5
0
ファイル: FormOrg.cs プロジェクト: miguellgt/file-structures
        private long CopiarListaCubetasRec(long dirCub, CArchivo aO, CArchivo aN, int tamBloque)
        {
            Cubeta cubAux, nuevaCub = null;
            CBloque bloqAux;
            long sigCub = -1;

            if( dirCub != -1)
            {
                cubAux = aO.LeerCubetaHashEstatica(dirCub);
                sigCub = CopiarListaCubetasRec(cubAux.getSigCubeta(), aO, aN, tamBloque);

                nuevaCub = new Cubeta(aN.ENDF(), cubAux.getTamaño());

                nuevaCub.setNumDirBloques(cubAux.getNumDirBloques());

                for (int i = 0; i < cubAux.getTamaño(); i++)
                    if ((bloqAux = aO.leerBloque(cubAux.getAtDirBloque(i), tamBloque)) != null)
                    {
                        bloqAux.setTamBlo(tamBloque);
                        nuevaCub.setAtDirBloque(i, aN.ENDF());
                        aN.EscribeBloque(bloqAux, aN.ENDF());
                    }

                nuevaCub.setDir(aN.ENDF());
                nuevaCub.setSigCubeta(sigCub);
                aN.EscribeCubetaHashEstatia(nuevaCub);
                sigCub = nuevaCub.getDir();
            }

            return (sigCub);
        }
コード例 #6
0
ファイル: FormOrg.cs プロジェクト: miguellgt/file-structures
        private CNodo creaNodo(CArchivo aO, CArchivo aN, CNodo nodoAux)
        {
            CNodo nuevo;

            nuevo = new CNodo(nodoAux.getTipoNodo(), nodoAux.getGrado());

            nuevo.setNumElemnt(nodoAux.getNumElemnt());
            nuevo.setTipoClave(nodoAux.getTipoClave());

            for(int i = 0; i< nodoAux.getNumElemnt(); i++)
            {
                nuevo.setAtDirClaves(i, aN.ENDF());
                nuevo.escribeClave(nodoAux.getAtClave(i), aN.ENDF(), nodoAux.getTipoClave(), aN);
            }

            nuevo.setDir(aN.ENDF());
            aN.escribeNodo(nuevo);

            return (nuevo);

        }
コード例 #7
0
ファイル: FormOrg.cs プロジェクト: miguellgt/file-structures
        /**Crea cada uno de los nodos de arbol en forma recursiva, asindo un recorrido en preorden
         * y va agranagando todos estos nodos al nuevo archivo*/
        public long generaArbolRec(CArchivo aO, CArchivo aD, int tamBloque, long dirCab)
        {
            CNodo nodoAux, nuevoNodo;
            CBloque bloqueAux,bloqueNuevo;
            long dirNodo = -1;
            int LS;

            if (dirCab != -1)
            {
                nodoAux = aO.leerNodo(dirCab);
                nuevoNodo = creaNodo(aO,aD,nodoAux);
                
                if (nodoAux.getTipoNodo() == HOJA || nodoAux.getTipoNodo() == RAIZHOJA)
                    LS = nodoAux.getNumElemnt();
                else
                    LS = nodoAux.getNumElemnt() + 1;

                for (int i = 0; i < LS; i++)
                    if (nodoAux.getTipoNodo() == HOJA || nodoAux.getTipoNodo() == RAIZHOJA)
                    {
                        bloqueAux = aO.leerBloque(nodoAux.getAtDirNodo(i), tamBloque);
                        bloqueNuevo = new CBloque();
                        bloqueNuevo.setBloque(bloqueAux.getBloque());
                        bloqueNuevo.setTamBlo(tamBloque);
                        bloqueNuevo.setDir(aD.ENDF());
                        aD.EscribeBloque(bloqueNuevo, aD.ENDF());
                        nuevoNodo.setAtDirNodo(i, bloqueNuevo.getDir());
                    }
                    else
                       nuevoNodo.setAtDirNodo(i,generaArbolRec(aO,aD,tamBloque,nodoAux.getAtDirNodo(i)));

               aD.escribeNodo(nuevoNodo);
               dirNodo = nuevoNodo.getDir();
             
            }

            return(dirNodo);   
        }
コード例 #8
0
ファイル: FormOrg.cs プロジェクト: miguellgt/file-structures
        /**Función de Mantenimiento para la Organizacion Secuencial indexada*/
        public void MantenimientoSecInd(CArchivo fileOri, CArchivo fileNew, CNodoEntidad ent, CNodoEntidad entC, int tamBloque)
        {
            List<CBloque> listBloque;
            List<CIndice> listaInd;
            CIndice indPri,nuevoInd;
            long aux;
            
            listaInd = new List<CIndice>();
            
            aux = ent.getApCabDatos();
            
            while (aux != -1)
            {
                indPri = fileOri.LeerIndicePrimario(aux);
                nuevoInd = new CIndice();

                nuevoInd.setIndPrim(indPri.getIndPrim());
                nuevoInd.setTamIndPri(indPri.getTamIndPri());
                nuevoInd.setTipoInd(indPri.getTipoInd());

                listBloque = new List<CBloque>();
                
                CopiarSec(fileOri, fileNew, indPri.getCabBloques(), tamBloque, ref listBloque);
                
                nuevoInd.setDirInd(fileNew.ENDF());
                nuevoInd.setCabBloques(listBloque[0].getDir());
                fileNew.EscribeIndicePrimario(nuevoInd);
                
                listaInd.Add(nuevoInd);
                
                aux = indPri.getSigInd();
            }

            for (int i = 0; i < listaInd.Count - 1; i++)
            {
                listaInd[i].setSigInd(listaInd[i + 1].getDirInd());
                fileNew.EscribeIndicePrimario((listaInd[i]));
            }
            
            entC.setApCabDatos(listaInd[0].getDirInd());
            fileNew.escribeEntidad(entC, ent.getDir());
        }
コード例 #9
0
ファイル: FormOrg.cs プロジェクト: miguellgt/file-structures
        /**Copia toda la lista de bloques al nuevo archivo*/
        public void CopiarSec(CArchivo fileOri, CArchivo fileNew, long dirEnt, int tamBloque, ref List<CBloque> listBloque)
        {
            CBloque bloqueAux, bloqueNuevo;
            
            while (dirEnt != -1)
            {
                bloqueAux = fileOri.leerBloque(dirEnt, tamBloque);
                bloqueNuevo = new CBloque();
                bloqueNuevo.setBloque(bloqueAux.getBloque());
                bloqueNuevo.setTamBlo(tamBloque);
                bloqueNuevo.setDir(fileNew.ENDF());
                fileNew.EscribeBloque(bloqueNuevo, fileNew.ENDF());
                listBloque.Add(bloqueNuevo);
                dirEnt = bloqueAux.getSigBlo();
            }

            for (int i = 0; i < listBloque.Count - 1; i++)
            {
                listBloque[i].setSigBlo(listBloque[i + 1].getDir());
                fileNew.EscribeBloque(listBloque[i], listBloque[i].getDir());
            }
        }
コード例 #10
0
 /**Se incrementa la tabla de direccionesa 2(i)*/
 public void Incrementate(CArchivo file)
 { 
     CEntrada nueva, aux, aux2;
     int numEntradas, idAux;
     
     numEntradas = listaEntradas.Count;
  
     for (int i = 0; i < numEntradas; i++)
     {
         aux = getAtEntrada(i);
         idAux = aux.getID();
         nueva = new CEntrada(aux.getCubeta(), getAtEntrada(getListEntradas().Count - 1).getID() + 1, file.ENDF());
         insEntrada(nueva);
         file.EscribeEntrada(nueva);
         aux2 = getAtEntrada(getListEntradas().Count - 2);
         aux2.setSigEntrada(nueva.getDir());
         file.EscribeEntrada(aux2);
     }
     
     EstableceEspejos(file);//Se actulizan los espejos
     file.EscribeTablaHashExt(this);
 }