/**Inserta un atribuoto, el entidad especificada*/
        public void insAtributo(CNodoAtributo nuevo, CNodoEntidad ent)
        {
            CNodoAtributo aux, ant = null;

            aux = ent.getCabListAtri();

            while (aux != null)
            {
                ant = aux;
                aux = aux.getSigAtri();
            }

            if (aux == ent.getCabListAtri())
                ent.setCabListAtri(nuevo);
            else
                ant.setSigAtri(nuevo);

            nuevo.setSigAtri(aux);
       }
Example #2
0
        /**\brief Inserta un atributo */
        public void AltaAtributo(CNodoAtributo nuevo, string nameEnt)
        {
            /**
             * \details
             * \param nuevo Atributo a insertar
             * \param nameEnt Nombre de la entidad a la pertenece el atributo
             * */
             
            CNodoEntidad nodoEnt = null;
            long ptrAux, ptrAnt = 0;
            CNodoAtributo aux, ant = null;
            bool band = false;

            AbrirArchivo();

            buscaEntidad(ref nodoEnt, nameEnt);

            aux = nodoEnt.getCabListAtri();
            ptrAux = nodoEnt.getApCabListAtri();

            while (aux != null)//Busqueda dell atributo
                if (aux.getNombre().CompareTo(nuevo.getNombre()) < 0)
                {
                    ant = aux;
                    ptrAnt = ptrAux;
                    ptrAux = aux.getApSigAtri();
                    aux = aux.getSigAtri();
                }
                else
                {
                    if (aux.getNombre().CompareTo(nuevo.getNombre()) == 0)
                        band = true;

                    break;
                }

            if (aux == nodoEnt.getCabListAtri())
            {
                if (band == false)
                {
                    nodoEnt.setApCabListAtri(fs.Length);
                    nodoEnt.setCabListAtri(nuevo);
                    escribeEntidad(nodoEnt, nodoEnt.getDir());
                }
            }
            else
                if (band == false)
                {
                    ant.setApSigAtri(fs.Length);
                    ant.setSigAtri(nuevo);
                    escribeAtributo(ant, ptrAnt);
                }

            if (band == false)
            {
                nuevo.setSigAtri(aux);
                nuevo.setApSigAtri(ptrAux);
                nuevo.setDir(fs.Length);
                escribeAtributo(nuevo, fs.Length);
            }

            CerrarArchivo();
        }