public FormHash() { InitializeComponent(); archivo = new Archivo("Untitle", Application.StartupPath + "\\ProyectosGrafo\\Hash\\"); registro = new CRegistro(26); tabla = new TablaHash(26, 4, 10, 10); }
public HashEstatico(TablaHash tabla, string path, string nombre, int noRegistros) { this.tabla = tabla; this.path = path; this.nombre = nombre; this.noRegistros = noRegistros; }
private void buttonCerrar_Click(object sender, EventArgs e) { HabilitarAbrirCrear(true); tabla = new TablaHash(26, 4, 10, 10); archivo = new Archivo("Untitle", Application.StartupPath + "\\ProyectosGrafo\\Hash\\"); registro = new CRegistro(26); nombreArch = ""; HabilitarEliminaAgrega(false); buttonCerrar.Enabled = false; LimpiarCubeta(); LimpiarTablaHash(); textBoxCV.Text = "0"; textBoxN1.Text = ""; textBoxN2.Text = ""; }
private void buttonCrear_Click(object sender, EventArgs e) { if (nombreArch != "") { if (!File.Exists(path + nombreArch)) { if (!DatVacio()) { tabla = new TablaHash(26, (int)numericNoReg.Value, (int)numericCajas.Value, (int)numericCajas.Value); archivo.EscribirTablaH(tabla); LimpiarCubeta(); MuestraDatos(); LimpiarTablaHash(); MuestraTabla(); HabilitarAbrirCrear(false); buttonCerrar.Enabled = true; HabilitarEliminaAgrega(true); } else { MessageBox.Show ( "Campos Vacios !!!", "Danger", MessageBoxButtons.OK, MessageBoxIcon.Exclamation ); } } else { MessageBox.Show ( "El Archivo Ya Existe !!!", "Danger", MessageBoxButtons.OK, MessageBoxIcon.Exclamation ); } //textBoxN1.Text = ""; } }
public long EscribirTablaH(TablaHash tabla) { long dir; using (fs = new FileStream(path + nombre, FileMode.OpenOrCreate, FileAccess.ReadWrite)) { fs.Seek(0, SeekOrigin.Begin); dir = fs.Position; using (var bw = new BinaryWriter(fs)) { bw.Write(tabla.NoCubetas); bw.Write(tabla.NoRegistros); bw.Write(tabla.TamRegistro); bw.Write(tabla.PtrsCubetaVacia); for (int i = 0; i < tabla.MAX; i++) { bw.Write(tabla.Cajones[i]); } } } return(dir); }
public void LeerTabla(long dir, TablaHash tabla) { using (fs = new FileStream(path + nombre, FileMode.Open, FileAccess.Read)) { fs.Seek(dir, SeekOrigin.Begin); byte[] a = new byte[sizeof(int)]; fs.Read(a, 0, sizeof(int)); tabla.NoCubetas = BitConverter.ToInt32(a, 0); fs.Read(a, 0, sizeof(int)); tabla.NoRegistros = BitConverter.ToInt32(a, 0); fs.Read(a, 0, sizeof(int)); tabla.TamRegistro = BitConverter.ToInt32(a, 0); a = new byte[sizeof(long)]; fs.Read(a, 0, sizeof(long)); tabla.PtrsCubetaVacia = BitConverter.ToInt64(a, 0); for (int i = 0; i < tabla.MAX; i++) { fs.Read(a, 0, sizeof(long)); tabla.Cajones[i] = BitConverter.ToInt64(a, 0); } } }