修改iterator ToHead ToTail的实现, 和使用方法.
This commit is contained in:
@@ -152,7 +152,14 @@ func TestTreeSet_Iterator(t *testing.T) {
|
||||
|
||||
iter := set.Iterator()
|
||||
iter.ToHead()
|
||||
// 3 4 5
|
||||
|
||||
// if not call Next Prev will error
|
||||
// 5 4 3
|
||||
// if iter.Value() != nil {
|
||||
// t.Error(iter.Value())
|
||||
// }
|
||||
|
||||
iter.Next()
|
||||
if iter.Value() != 3 {
|
||||
t.Error(iter.Value())
|
||||
}
|
||||
@@ -162,12 +169,8 @@ func TestTreeSet_Iterator(t *testing.T) {
|
||||
t.Error(iter.Value())
|
||||
}
|
||||
|
||||
iter.Next()
|
||||
if iter.Value() != 5 {
|
||||
t.Error(iter.Value())
|
||||
}
|
||||
|
||||
iter.ToTail()
|
||||
iter.Prev()
|
||||
if iter.Value() != 5 {
|
||||
t.Error(iter.Value())
|
||||
}
|
||||
@@ -176,4 +179,16 @@ func TestTreeSet_Iterator(t *testing.T) {
|
||||
if iter.Value() != 4 {
|
||||
t.Error(iter.Value())
|
||||
}
|
||||
|
||||
iter.ToHead()
|
||||
iter.Prev()
|
||||
if iter.Value() != 3 {
|
||||
t.Error(iter.Value())
|
||||
}
|
||||
|
||||
iter.ToTail()
|
||||
iter.Next()
|
||||
if iter.Value() != 5 {
|
||||
t.Error(iter.Value())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user