Documentation
¶
Overview ¶
Package linkedlist provides functionality for creating and manipulating doubly linked lists.
Index ¶
- func AddFirst[T any](ll *LinkedList[T], n *Node[T])
- func AddLast[T any](ll *LinkedList[T], n *Node[T])
- func Clear[T any](ll *LinkedList[T])
- func Contains[T comparable](ll *LinkedList[T], e *T) bool
- func ContainsWith[T any](ll *LinkedList[T], e *T, p func(*T, *T) bool) bool
- func Insert[T any](ll *LinkedList[T], index int, n *Node[T])
- func Remove[T any](ll *LinkedList[T], index int)
- func ToSlice[T any](ll LinkedList[T]) (s []T)
- type LinkedList
- type Node
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddFirst ¶
func AddFirst[T any](ll *LinkedList[T], n *Node[T])
AddFirst adds a node to the beginning of the linked list.
func AddLast ¶
func AddLast[T any](ll *LinkedList[T], n *Node[T])
AddLast adds a node to the end of the linked list.
func Clear ¶
func Clear[T any](ll *LinkedList[T])
Clear removes all elements from the linked list. Breaks all connections between nodes and sets the head and tail to nil.
func Contains ¶
func Contains[T comparable](ll *LinkedList[T], e *T) bool
Contains returns true if the linked list contains the element as a value in a node.
func ContainsWith ¶
func ContainsWith[T any](ll *LinkedList[T], e *T, p func(*T, *T) bool) bool
ContainsWith returns true if the linked list contains the element as a value in a node using the provided comparator.
func Insert ¶
func Insert[T any](ll *LinkedList[T], index int, n *Node[T])
Insert inserts the element at the specified index. Index 0 is the head of the list.
func Remove ¶
func Remove[T any](ll *LinkedList[T], index int)
Remove removes the element at the specified index. Index 0 is the head of the list.
func ToSlice ¶
func ToSlice[T any](ll LinkedList[T]) (s []T)
ToSlice returns a slice from a linked list.
Types ¶
type LinkedList ¶
LinkedList is a doubly linked list.
func FromSlice ¶
func FromSlice[T any](s []T) (ll LinkedList[T])
FromSlice returns a linked list from a slice/array.