예제 #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)
		}
	}
}
예제 #2
0
func main() {
	h := OverflowHash.NewHashTable(10)
	var p [5]*OverflowHash.ElemType
	p[0] = OverflowHash.NewElem(62, 1)
	p[1] = OverflowHash.NewElem(17, 2)
	p[2] = OverflowHash.NewElem(39, 3)
	p[3] = OverflowHash.NewElem(29, 4)
	p[4] = OverflowHash.NewElem(9, 5)

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

}