Beispiel #1
0
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))
	}
}
Beispiel #2
0
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))
	}
}
Beispiel #3
0
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())
	}
}
Beispiel #4
0
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)
	}
}
Beispiel #5
0
func New() *Queue {
	l := list.New(0)
	return &Queue{
		l: l,
	}
}
Beispiel #6
0
func New() *PriorityQueue {
	return &PriorityQueue{list.New()}
}