Package list
Overview ?
Overview ?
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 }
Index
- type Element
- func (e *Element) Next() *Element
- func (e *Element) Prev() *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{}
Package files
type Element
type Element struct { // The contents of this list element. Value interface{} // contains filtered or unexported fields }
Element is an element in the linked list.
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
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.
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) 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) interface{}
Remove removes the element from the list and returns its Value.
Except as noted, the content of this page is licensed under the Creative Commons Attribution 3.0 License, and code is licensed under a BSD license.
Terms of Service | Privacy Policy