Documentation ¶
Overview ¶
Package list provides an implementation of a doubly-linked list with a front and back. The individual nodes of the list are publicly exposed so that the user can have fine-grained control over the list.
Example ¶
package main import ( "fmt" "github.com/zendesk/generic/list" ) func main() { l := list.New[int]() l.PushBack(0) l.PushBack(1) l.PushBack(2) l.PushBack(3) l.Front.Each(func(i int) { fmt.Println(i) }) }
Output: 0 1 2 3
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type List ¶
List implements a doubly-linked list.
func (*List[V]) PushBack ¶
func (l *List[V]) PushBack(v V)
PushBack adds 'v' to the end of the list.
func (*List[V]) PushBackNode ¶
PushBackNode adds the node 'n' to the back of the list.
func (*List[V]) PushFront ¶
func (l *List[V]) PushFront(v V)
PushFront adds 'v' to the beginning of the list.
func (*List[V]) PushFrontNode ¶
PushFrontNode adds the node 'n' to the front of the list.
type Node ¶
Node is a node in the linked list.
func (*Node[V]) Each ¶
func (n *Node[V]) Each(fn func(val V))
Each calls 'fn' on every element from this node onward in the list.
func (*Node[V]) EachReverse ¶
func (n *Node[V]) EachReverse(fn func(val V))
EachReverse calls 'fn' on every element from this node backward in the list.
Click to show internal directories.
Click to hide internal directories.