func TestCreateList1(t *testing.T) { l := list.New(10) for i := 0; i < 10; i++ { l.PushBack(i) fmt.Println(l.Size()) fmt.Println(l.Front().(int), l.Back().(int)) } }
func TestCreateList3(t *testing.T) { l := list.New(10) for i := 0; i < 10; i++ { l.Insert(int64(i), i) fmt.Println(l.Size()) fmt.Println(l.Front().(int), l.Back().(int)) } }
func TestPop(t *testing.T) { l := list.New(10) for i := 0; i < 10; i++ { l.PushBack(i) } for i := 0; i < 10; i++ { if i%2 == 1 { l.PopBack() } else { l.PopFront() } fmt.Println(l.Size(), l.Front(), l.Back()) } }
func TestRemove2(t *testing.T) { l := list.New(10) for i := 0; i < 10; i++ { l.PushBack(i) } l.EraseRange(3, 8) fmt.Println(l.Front()) fmt.Println("sz", l.Size()) for l.Size() > 0 { fmt.Println("sz", l.Size()) fmt.Println(l.Front()) l.Erase(0) } }
func New() *Queue { l := list.New(0) return &Queue{ l: l, } }
func New() *PriorityQueue { return &PriorityQueue{list.New()} }