algo/go/17_skiplist/skiplist_test.go

39 lines
956 B
Go
Raw Normal View History

2018-10-29 19:31:16 +08:00
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("-----------------------------")
}