import "container/list"
Package list implements a doubly linked list.
To iterate over a list (where l is a *List):
for e := l.Front(); e != nil; e = e.Next() { // do something with e.Value }
type Element struct { // The value stored with this element. Value interface{} // contains filtered or unexported fields }
Element is an element of a linked list.
Next returns the next list element or nil.
Prev returns the previous list element or nil.
type List struct {
// contains filtered or unexported fields
}
List represents a doubly linked list. The zero value for List is an empty list ready to use.
New returns an initialized list.
Back returns the last element of list l or nil if the list is empty.
Front returns the first element of list l or nil if the list is empty.
Init initializes or clears list l.
InsertAfter inserts a new element e with value v immediately after mark and returns e. If mark is not an element of l, the list is not modified. The mark must not be nil.
InsertBefore inserts a new element e with value v immediately before mark and returns e. If mark is not an element of l, the list is not modified. The mark must not be nil.
Len returns the number of elements of list l. The complexity is O(1).
MoveAfter moves element e to its new position after mark. If e or mark is not an element of l, or e == mark, the list is not modified. The element and mark must not be nil.
MoveBefore moves element e to its new position before mark. If e or mark is not an element of l, or e == mark, the list is not modified. The element and mark must not be nil.
MoveToBack moves element e to the back of list l. If e is not an element of l, the list is not modified. The element must not be nil.
MoveToFront moves element e to the front of list l. If e is not an element of l, the list is not modified. The element must not be nil.
PushBack inserts a new element e with value v at the back of list l and returns e.
PushBackList inserts a copy of another list at the back of list l. The lists l and other may be the same. They must not be nil.
PushFront inserts a new element e with value v at the front of list l and returns e.
PushFrontList inserts a copy of another list at the front of list l. The lists l and other may be the same. They must not be nil.
Remove removes e from l if e is an element of list l. It returns the element value e.Value. The element must not be nil.
Package list is imported by 12325 packages. Updated 2021-01-21. Refresh now. Tools for package owners.