mirror of
https://github.com/tursom/GoCollections.git
synced 2025-01-01 15:31:31 +08:00
28 lines
475 B
Go
28 lines
475 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"collections/collections"
|
||
|
"fmt"
|
||
|
)
|
||
|
|
||
|
func main() {
|
||
|
list := collections.NewLinkedList()
|
||
|
fmt.Println(list)
|
||
|
for i := 0; i < 20; i++ {
|
||
|
list.Add(i)
|
||
|
//fmt.Println(list)
|
||
|
}
|
||
|
|
||
|
_ = collections.LoopMutable(list, func(element interface{}, iterator collections.MutableIterator) error {
|
||
|
if element.(int)&1 == 0 {
|
||
|
iterator.Remove()
|
||
|
}
|
||
|
fmt.Println(list)
|
||
|
return nil
|
||
|
})
|
||
|
//for i := 0; i < 10; i++ {
|
||
|
// list.Remove(i * 2)
|
||
|
// fmt.Println(list)
|
||
|
//}
|
||
|
}
|