Documentation
¶
Overview ¶
Package list provides a doubly linked list built around reusable, caller-owned nodes.
Index ¶
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 is a doubly linked list. Lists must be created with New.
func (*List[T]) InsertAfter ¶
InsertAfter inserts n after mark, which must be a node of l. It has the same contract for n as List.PushBack.
func (*List[T]) InsertBefore ¶
InsertBefore inserts n before mark. It has the same contract as List.InsertAfter.
func (*List[T]) PushBack ¶
PushBack inserts n at the back of the list. n can be a detached node or a node of l, in which case it is moved to the new position. Pushing a node of another list is a no-op - detach it first.
func (*List[T]) PushFront ¶
PushFront inserts n at the front of the list. It has the same contract for n as List.PushBack.
type Node ¶
type Node[T any] struct { Value T // contains filtered or unexported fields }
Node is a node of a List. The zero value is a detached node ready to be inserted into a list.
func (*Node[T]) Detach ¶
func (n *Node[T]) Detach()
Detach removes n from the list it belongs to. It is a no-op if n is already detached.