Documentation
¶
Overview ¶
Package glinklist implements a doubly linked list.
To iterate over a list (where l is a *LinkList):
for e := l.Front(); e != nil; e = e.Next() { // do something with e.Value }
Index ¶
- type Element
- type LinkList
- func (l *LinkList) Back() *Element
- func (l *LinkList) Clone() *LinkList
- func (l *LinkList) Front() *Element
- func (l *LinkList) IndexOf(v interface{}) int
- func (l *LinkList) Init() *LinkList
- func (l *LinkList) InsertAfter(v interface{}, mark *Element) *Element
- func (l *LinkList) InsertBefore(v interface{}, mark *Element) *Element
- func (l *LinkList) Len() int64
- func (l *LinkList) MoveAfter(e, mark *Element)
- func (l *LinkList) MoveBefore(e, mark *Element)
- func (l *LinkList) MoveToBack(e *Element)
- func (l *LinkList) MoveToFront(e *Element)
- func (l *LinkList) PushBack(v interface{}) *Element
- func (l *LinkList) PushBackList(other *LinkList)
- func (l *LinkList) PushFront(v interface{}) *Element
- func (l *LinkList) PushFrontList(other *LinkList)
- func (l *LinkList) Range(f func(v interface{}) bool)
- func (l *LinkList) Remove(e *Element) interface{}
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Element ¶
type Element struct { // The value stored with this element. Value interface{} // contains filtered or unexported fields }
Element is an element of a linked list.
type LinkList ¶
LinkList represents a doubly linked list. The zero value for LinkList is an empty list ready to use.
func (*LinkList) IndexOf ¶
IndexOf returns the value first occurs index in the linklist, index starts with 0. if not found return -1.
func (*LinkList) InsertAfter ¶
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.
func (*LinkList) InsertBefore ¶
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.
func (*LinkList) MoveAfter ¶
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.
func (*LinkList) MoveBefore ¶
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.
func (*LinkList) MoveToBack ¶
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.
func (*LinkList) MoveToFront ¶
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.
func (*LinkList) PushBack ¶
PushBack inserts a new element e with value v at the back of list l and returns e.
func (*LinkList) PushBackList ¶
PushBackList inserts a copy of an other list at the back of list l. The lists l and other may be the same. They must not be nil.
func (*LinkList) PushFront ¶
PushFront inserts a new element e with value v at the front of list l and returns e.
func (*LinkList) PushFrontList ¶
PushFrontList inserts a copy of an other list at the front of list l. The lists l and other may be the same. They must not be nil.