Example #1
0
func main() {
	fmt.Println("The fill factor test:")
	size := 100
	factor := 10n 

	for ; factor <= size; factor = factor + 10 {
		ch := ClosedHash.NewHashTable(size)
		oh := OpenHash.NewHashTable(size)
		ofh := OverflowHash.NewHashTable(size)
		rand.Seed(time.Now().Unix())
		for i := 0; i < factor; i++ {
			k := rand.Int() / 100
			d := rand.Int()
			ce := ClosedHash.NewElem(k, d)
			oe := OpenHash.NewElem(k, d)
			ofe := OverflowHash.NewElem(k, d)
			ch.Insert(ce)
			oh.Insert(oe)
			ofh.Insert(ofe)
		}
		ft := time.Now()
		for i := 0; i < 10000; i++{
			ch.Find(rand.Int()/100)
		}
	}
}
Example #2
0
func main() {
	h := ClosedHash.NewHashTable(10)
	var p [5]*ClosedHash.ElemType
	ClosedHash.HashType = 1
	p[0] = ClosedHash.NewElem(62, 1)
	p[1] = ClosedHash.NewElem(17, 2)
	p[2] = ClosedHash.NewElem(39, 3)
	p[3] = ClosedHash.NewElem(29, 4)
	p[4] = ClosedHash.NewElem(9, 5)

	for i := 0; i < 5; i++ {
		h.Insert(*p[i])
	}
	fmt.Println(h)
	h.Traverse(ClosedHash.Print)
	h.Find(17)
	h.Delete(17)
	h.Traverse(ClosedHash.Print)

}