Documentation
¶
Overview ¶
Package list provides generic 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
- type List
- func (l *List[V]) Back() *Element[V]
- func (l *List[V]) Front() *Element[V]
- func (l *List[V]) Init() *List[V]
- func (l *List[V]) InsertAfter(v V, mark *Element[V]) *Element[V]
- func (l *List[V]) InsertBefore(v V, mark *Element[V]) *Element[V]
- func (l *List[V]) Len() int
- func (l *List[V]) MoveAfter(e, mark *Element[V])
- func (l *List[V]) MoveBefore(e, mark *Element[V])
- func (l *List[V]) MoveToBack(e *Element[V])
- func (l *List[V]) MoveToFront(e *Element[V])
- func (l *List[V]) PushBack(v V) *Element[V]
- func (l *List[V]) PushBackList(other *List[V])
- func (l *List[V]) PushFront(v V) *Element[V]
- func (l *List[V]) PushFrontList(other *List[V])
- func (l *List[V]) Remove(e *Element[V]) V
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Element ¶
type Element[V any] struct { // The value stored with this element. Value V // contains filtered or unexported fields }
Element is an element of a linked list.
func NewElement ¶
NewElement returns an unbound element.
type List ¶
type List[V any] 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 (*List[V]) 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 (*List[V]) 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 (*List[V]) MoveAfter ¶
MoveAfter moves element e to its new position after mark. If e or mark is an element of another list, or e == mark, the list is not modified. The element and mark must not be nil.
func (*List[V]) MoveBefore ¶
MoveBefore moves element e to its new position before mark. If e or mark is an element of another list, or e == mark, the list is not modified. The element and mark must not be nil.
func (*List[V]) MoveToBack ¶
MoveToBack moves element e to the back of list l. If e is an element of another list, the list is not modified. The element must not be nil.
func (*List[V]) MoveToFront ¶
MoveToFront moves element e to the front of list l. If e is an element of another list, the list is not modified. The element must not be nil.
func (*List[V]) PushBack ¶
PushBack inserts a new element e with value v at the back of list l and returns e.
func (*List[V]) PushBackList ¶
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.
func (*List[V]) PushFront ¶
PushFront inserts a new element e with value v at the front of list l and returns e.
func (*List[V]) PushFrontList ¶
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.