list包实现了双向链表的功能。
遍历一个list的代码实例(其中l
为*list对象):
for e := l.Front(); e != nil; e = e.Next() {
// do something with e.Value
}
- type Element
- type List
- func New() *List
- func (l *List) Back() *Element
- func (l *List) Front() *Element
- func (l *List) Init() *List
- func (l *List) InsertAfter(value interface{}, mark *Element) *Element
- func (l *List) InsertBefore(value interface{}, mark *Element) *Element
- func (l *List) Len() int
- func (l *List) MoveToBack(e *Element)
- func (l *List) MoveToFront(e *Element)
- func (l *List) PushBack(value interface{}) *Element
- func (l *List) PushBackList(ol *List)
- func (l *List) PushFront(value interface{}) *Element
- func (l *List) PushFrontList(ol *List)
- func (l *List) Remove(e *Element) interface{}