algo/go/17_skiplist/skiplist_test.go
leotyliu(刘天一) 55690465e4 跳表 by golang
2018-10-29 19:31:16 +08:00

39 lines
956 B
Go

package _7_skiplist
import "testing"
func TestSkipList(t *testing.T) {
sl := NewSkipList()
sl.Insert("leo", 95)
t.Log(sl.head.forwards[0])
t.Log(sl.head.forwards[0].forwards[0])
t.Log(sl)
t.Log("-----------------------------")
sl.Insert("jack", 88)
t.Log(sl.head.forwards[0])
t.Log(sl.head.forwards[0].forwards[0])
t.Log(sl.head.forwards[0].forwards[0].forwards[0])
t.Log(sl)
t.Log("-----------------------------")
sl.Insert("lily", 100)
t.Log(sl.head.forwards[0])
t.Log(sl.head.forwards[0].forwards[0])
t.Log(sl.head.forwards[0].forwards[0].forwards[0])
t.Log(sl.head.forwards[0].forwards[0].forwards[0].forwards[0])
t.Log(sl)
t.Log("-----------------------------")
t.Log(sl.Find("jack", 88))
t.Log("-----------------------------")
sl.Delete("leo", 95)
t.Log(sl.head.forwards[0])
t.Log(sl.head.forwards[0].forwards[0])
t.Log(sl.head.forwards[0].forwards[0].forwards[0])
t.Log(sl)
t.Log("-----------------------------")
}