public void alta(string llave, long dir) { NodoIndicePrimario nodoIndicePrimario; nodoIndicePrimario = new NodoIndicePrimario(llave, dir); this.idx[this.EspacioLibre] = nodoIndicePrimario; this.idx = idx.OrderBy(nodo => nodo.Llave).ToArray(); }
public Primario(string nombre, long dirAct, int tamañoArreglo, long dirSig) : base(nombre, dirAct, dirSig) { this.tamañoArreglo = tamañoArreglo; this.idx = new NodoIndicePrimario[tamañoArreglo]; for (int i = 0; i < tamañoArreglo; i++) { idx[i] = new NodoIndicePrimario("-1", -1); } }
private void leeIndicePrimario(string directorio) { try { Indice indice; long dirSig; int largo; string llave; long direccion; llave = "-1"; direccion = -1; dirSig = this.dirIndice; largo = MetodosAuxiliares.calculaTamIdxPrim(this.longitud); NodoIndicePrimario[] nodos; nodos = new NodoIndicePrimario[largo]; NodoIndicePrimario nodo; while (dirSig != -1) { using (reader = new BinaryReader(new FileStream(directorio, FileMode.Open)))//Abre el archivo con el BinaryWriter { reader.BaseStream.Seek(this.dirIndice, SeekOrigin.Current); for (int i = 0; i < largo; i++) { if (this.tipo == 'C') { llave = new string(this.reader.ReadChars(this.longitud)); } else { llave = this.reader.ReadInt32().ToString(); } direccion = this.reader.ReadInt64(); nodo = new NodoIndicePrimario(llave, direccion); nodos[i] = nodo; } indice = new Primario(this.nombre, dirSig, nodos, largo, -1); this.indices.Add(indice); dirSig = reader.ReadInt64(); } } for (int i = 0; i < this.Indices.Count - 1; i++) { this.indices[i].DirSig = this.indices[i + 1].DirAct; } } catch (Exception e) { MessageBox.Show(e.Message); } }