Documentation
¶
Index ¶
- type LinkedList
- func (ll *LinkedList[T]) Append(value T)
- func (ll *LinkedList[T]) Find(value T) *Node[T]
- func (ll *LinkedList[T]) Head() *Node[T]
- func (ll *LinkedList[T]) InsertAt(pos int, value T) error
- func (ll *LinkedList[T]) IsEmpty() bool
- func (ll *LinkedList[T]) Pop()
- func (ll *LinkedList[T]) PopHead()
- func (ll *LinkedList[T]) PushHead(value T)
- func (ll *LinkedList[T]) Size() uint
- func (ll *LinkedList[T]) String() string
- func (ll *LinkedList[T]) Tail() *Node[T]
- type Node
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LinkedList ¶
type LinkedList[T any] struct { // contains filtered or unexported fields }
LinkedList is a linked list.
func NewLinkedList ¶
func NewLinkedList[T any](cmp func(T, T) int) *LinkedList[T]
NewLinkedList returns a new linked list.
func (*LinkedList[T]) Append ¶
func (ll *LinkedList[T]) Append(value T)
Append adds a new node to the end of the list.
func (*LinkedList[T]) Find ¶
func (ll *LinkedList[T]) Find(value T) *Node[T]
Find returns the node with the given value.
func (*LinkedList[T]) Head ¶
func (ll *LinkedList[T]) Head() *Node[T]
Head returns the head node of the list.
func (*LinkedList[T]) InsertAt ¶
func (ll *LinkedList[T]) InsertAt(pos int, value T) error
InsertAt adds a new node to the given position
func (*LinkedList[T]) IsEmpty ¶
func (ll *LinkedList[T]) IsEmpty() bool
IsEmpty returns true if the list is empty.
func (*LinkedList[T]) PopHead ¶
func (ll *LinkedList[T]) PopHead()
PopHead removes the first node from the list.
func (*LinkedList[T]) PushHead ¶
func (ll *LinkedList[T]) PushHead(value T)
PushHead adds a new node to the head of the list.
func (*LinkedList[T]) Size ¶
func (ll *LinkedList[T]) Size() uint
Size returns the size of the list.
func (*LinkedList[T]) String ¶
func (ll *LinkedList[T]) String() string
String returns a string representation of the list.
func (*LinkedList[T]) Tail ¶
func (ll *LinkedList[T]) Tail() *Node[T]
Tail returns the tail node of the list.
Click to show internal directories.
Click to hide internal directories.