mirror of
https://github.com/duanhf2012/origin.git
synced 2026-02-14 15:54:42 +08:00
优化循环队列test
This commit is contained in:
@@ -12,7 +12,7 @@ func Test_Example(t *testing.T) {
|
||||
t.Log("is empty :", queue.IsEmpty())
|
||||
t.Log("is full :", queue.IsFull())
|
||||
|
||||
//3.游标使用
|
||||
//3.游标使用,打印所有数据
|
||||
cursor := queue.GetCursor()
|
||||
cursor.First()
|
||||
for {
|
||||
@@ -23,7 +23,7 @@ func Test_Example(t *testing.T) {
|
||||
t.Log("elem:", elem)
|
||||
}
|
||||
|
||||
//4.push数据
|
||||
//4.push数据,塞满队列
|
||||
for i := 0; i < 6; i++ {
|
||||
t.Log("push:", queue.Push(i))
|
||||
}
|
||||
@@ -31,7 +31,7 @@ func Test_Example(t *testing.T) {
|
||||
t.Log("is empty :", queue.IsEmpty())
|
||||
t.Log("is full :", queue.IsFull())
|
||||
|
||||
//5.游标遍历
|
||||
//5.使用游标遍历所有数据
|
||||
cursor.First()
|
||||
for {
|
||||
elem, ret := cursor.Next()
|
||||
@@ -41,7 +41,21 @@ func Test_Example(t *testing.T) {
|
||||
t.Log("elem:", elem)
|
||||
}
|
||||
|
||||
//pop数据所有
|
||||
//6.删除2个元素
|
||||
removeNum := queue.RemoveElement(2)
|
||||
t.Log("Remove Num:", removeNum)
|
||||
|
||||
//7.游标遍历
|
||||
cursor.First()
|
||||
for {
|
||||
elem, ret := cursor.Next()
|
||||
if ret == false {
|
||||
break
|
||||
}
|
||||
t.Log("elem:", elem)
|
||||
}
|
||||
|
||||
//8.pop数据所有
|
||||
for i := 0; i < 6; i++ {
|
||||
elem, ret := queue.Pop()
|
||||
t.Log("pop:", elem, "-", ret, " len:", queue.Len())
|
||||
|
||||
Reference in New Issue
Block a user