示例#1
0
文件: list_test.go 项目: qoshi/gostd
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))
	}
}
示例#2
0
文件: list_test.go 项目: qoshi/gostd
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))
	}
}
示例#3
0
文件: list_test.go 项目: qoshi/gostd
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())
	}
}
示例#4
0
文件: list_test.go 项目: qoshi/gostd
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)
	}
}
示例#5
0
文件: queue.go 项目: qoshi/gostd
func New() *Queue {
	l := list.New(0)
	return &Queue{
		l: l,
	}
}
示例#6
0
func New() *PriorityQueue {
	return &PriorityQueue{list.New()}
}