Package list
import "container/list"
The list package implements a doubly linked list.
Package files
list.gotype Element
Element is an element in the linked list.
type Element struct {
// The contents of this list element.
Value interface{}
// contains unexported fields
}
func (*Element) Next
func (e *Element) Next() *Element
Next returns the next list element or nil.
func (*Element) Prev
func (e *Element) Prev() *Element
Prev returns the previous list element or nil.
type List
List represents a doubly linked list.
type List struct {
// contains unexported fields
}
func New
func New() *List
New returns an initialized list.
func (*List) Back
func (l *List) Back() *Element
Back returns the last element in the list.
func (*List) Front
func (l *List) Front() *Element
Front returns the first element in the list.
func (*List) Init
func (l *List) Init() *List
Init initializes or clears a List.
func (*List) InsertAfter
func (l *List) InsertAfter(value interface{}, mark *Element) *Element
InsertAfter inserts the value immediately after mark and returns a new Element containing the value.
func (*List) InsertBefore
func (l *List) InsertBefore(value interface{}, mark *Element) *Element
InsertBefore inserts the value immediately before mark and returns a new Element containing the value.
func (*List) Iter
func (l *List) Iter() <-chan interface{}
func (*List) Len
func (l *List) Len() int
Len returns the number of elements in the list.
func (*List) MoveToBack
func (l *List) MoveToBack(e *Element)
MoveToBack moves the element to the back of the list.
func (*List) MoveToFront
func (l *List) MoveToFront(e *Element)
MoveToFront moves the element to the front of the list.
func (*List) PushBack
func (l *List) PushBack(value interface{}) *Element
PushBack inserts the value at the back of the list and returns a new Element containing the value.
func (*List) PushBackList
func (l *List) PushBackList(ol *List)
PushBackList inserts each element of ol at the back of the list.
func (*List) PushFront
func (l *List) PushFront(value interface{}) *Element
PushFront inserts the value at the front of the list and returns a new Element containing the value.
func (*List) PushFrontList
func (l *List) PushFrontList(ol *List)
PushFrontList inserts each element of ol at the front of the list. The ordering of the passed list is preserved.
func (*List) Remove
func (l *List) Remove(e *Element)
Remove removes the element from the list.
