Involved Source Files
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
}
Code Examples
package main
import (
"container/list"
"fmt"
)
func main() {
// Create a new list and put some numbers in it.
l := list.New()
e4 := l.PushBack(4)
e1 := l.PushFront(1)
l.InsertBefore(3, e4)
l.InsertAfter(2, e1)
// Iterate through list and print its contents.
for e := l.Front(); e != nil; e = e.Next() {
fmt.Println(e.Value)
}
}
Package-Level Type Names (total 2, both are exported)
/* sort exporteds by: | */
Element is an element of a linked list.
The value stored with this element.
The list to which this element belongs.
Next and previous pointers in the doubly-linked list of elements.
To simplify the implementation, internally a list l is implemented
as a ring, such that &l.root is both the next element of the last
list element (l.Back()) and the previous element of the first list
element (l.Front()).
Next and previous pointers in the doubly-linked list of elements.
To simplify the implementation, internally a list l is implemented
as a ring, such that &l.root is both the next element of the last
list element (l.Back()) and the previous element of the first list
element (l.Front()).
Next returns the next list element or nil.
Prev returns the previous list element or nil.
func (*Element).Next() *Element
func (*Element).Prev() *Element
func (*List).Back() *Element
func (*List).Front() *Element
func (*List).InsertAfter(v interface{}, mark *Element) *Element
func (*List).InsertBefore(v interface{}, mark *Element) *Element
func (*List).PushBack(v interface{}) *Element
func (*List).PushFront(v interface{}) *Element
func (*List).insert(e, at *Element) *Element
func (*List).insertValue(v interface{}, at *Element) *Element
func (*List).move(e, at *Element) *Element
func (*List).remove(e *Element) *Element
func (*List).InsertAfter(v interface{}, mark *Element) *Element
func (*List).InsertBefore(v interface{}, mark *Element) *Element
func (*List).MoveAfter(e, mark *Element)
func (*List).MoveBefore(e, mark *Element)
func (*List).MoveToBack(e *Element)
func (*List).MoveToFront(e *Element)
func (*List).Remove(e *Element) interface{}
func (*List).insert(e, at *Element) *Element
func (*List).insertValue(v interface{}, at *Element) *Element
func (*List).move(e, at *Element) *Element
func (*List).remove(e *Element) *Element
List represents a doubly linked list.
The zero value for List is an empty list ready to use.
// current list length excluding (this) sentinel element
// sentinel list element, only &root, root.prev, and root.next are used
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.
insert inserts e after at, increments l.len, and returns e.
insertValue is a convenience wrapper for insert(&Element{Value: v}, at).
lazyInit lazily initializes a zero List value.
move moves e to next to at and returns e.
remove removes e from its list, decrements l.len, and returns e.
func New() *List
func (*List).Init() *List
func (*List).PushBackList(other *List)
func (*List).PushFrontList(other *List)
func github.com/neo4j/neo4j-go-driver/v4/neo4j/internal/pool.closeAndEmptyConnections(l List)
Package-Level Functions (only one, which is exported)
New returns an initialized list.
The pages are generated with Goldsv0.4.2. (GOOS=darwin GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds.