Documentation ¶
Overview ¶
Package list implements a doubly linked list. See https://en.wikipedia.org/wiki/Linked_list for more details.
Index ¶
- type List
- func (l *List[T]) All() []T
- func (l *List[T]) Back() T
- func (l *List[T]) ChangeAt(i int, value T)
- func (l *List[T]) Clear()
- func (l *List[T]) Cut(i int) (*List[T], *List[T])
- func (l *List[T]) Front() T
- func (l *List[T]) InsertAfter(node *Node[T], value T)
- func (l *List[T]) InsertBefore(n *Node[T], value T)
- func (l *List[T]) Len() int
- func (l *List[T]) Merge(other *List[T])
- func (l *List[T]) Node(i int) *Node[T]
- func (l *List[T]) Peek(i int) T
- func (l *List[T]) PopBack() T
- func (l *List[T]) PopFront() T
- func (l *List[T]) PushBack(value T)
- func (l *List[T]) PushFront(value T)
- func (l *List[T]) Remove(n *Node[T])
- func (l *List[T]) Reverse()
- type Node
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type List ¶
type List[T any] struct { // contains filtered or unexported fields }
List represents a doubly linked list. Zero value of List is empty list.
func (*List[T]) ChangeAt ¶
ChangeAt changes value at given index. Returns zero value if list is empty.
func (*List[T]) Cut ¶
Cut cuts list into two list. i is last element in first list, for example cut(1) for list {1,2,3,4,5} returns {1,2}, {3,4,5}.
func (*List[T]) InsertAfter ¶
InsertAfter adds new Node with given value after given Node.
func (*List[T]) InsertBefore ¶
InsertBefore adds new Node with given value before given Node.
func (*List[T]) Node ¶
Node returns Node at the given index. Returns zero value if index is less or equal to len of the list.
func (*List[T]) Peek ¶
Peek returns element at the given index. Returns zero value if index is less or equal to len of the list.
func (*List[T]) PopBack ¶
func (l *List[T]) PopBack() T
PopBack removes last element of the list. Returns zero value if list is empty.
func (*List[T]) PopFront ¶
func (l *List[T]) PopFront() T
PopFront removes first element of the list. Returns zero value if list is empty.
func (*List[T]) PushBack ¶
func (l *List[T]) PushBack(value T)
PushBack adds value to the end of the list.