Hashing

Solo disponible en BuenasTareas
  • Páginas : 2 (395 palabras )
  • Descarga(s) : 0
  • Publicado : 18 de noviembre de 2010
Leer documento completo
Vista previa del texto
-------------------------------------------------BALDE------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Hash.Hash{
class Balde
{
private List ranuras;
private int index;
private int rp;
private int rs;

public Balde(int rp, int rs)
{ranuras = new List();
Ranura ranuraPrincipal = new Ranura(rp);
ranuras.Add(ranuraPrincipal);
this.rp = rp;
this.rs = rs;
this.index = 0;}

public bool estaVacio()
{
foreach (Ranura ran in ranuras)
{
if (!ran.estaVacia())
{return false;
}
}
return true;
}

public bool Insert(int x)
{
Ranura r = ranuras.ElementAt(index);if (!r.estaLlena())
{
return r.Insert(x);
}
else
{
foreach (Ranura ran in ranuras)
{if (!ran.estaLlena())
{
return ran.Insert(x);
}
}

Ranura ranSec = new Ranura(rs);ranuras.Add(ranSec);
return ranSec.Insert(x);
}
}

public int getValue()
{
foreach (Ranura ran in ranuras){
if (!ran.estaVacia())
{
return ran.getValue();
}
}
return int.MinValue;
}public void print ()
{
int i = 0;
foreach (Ranura ran in ranuras)
{
Console.WriteLine("Ranura: " + i);
ran.print();...
tracking img