linkedlist

package
v0.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 15, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Index

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]) Pop

func (ll *LinkedList[T]) Pop()

Pop removes the last node from the list.

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.

type Node

type Node[T any] struct {
	// contains filtered or unexported fields
}

Node is a node in a linked list.

func NewNode

func NewNode[T any](value T) *Node[T]

NewNode returns a new linked list node.

func (*Node[T]) Next

func (node *Node[T]) Next() *Node[T]

Next returns the next node in the list.

func (*Node[T]) Prev

func (node *Node[T]) Prev() *Node[T]

Prev returns the previous node in the list.

func (*Node[T]) Value

func (node *Node[T]) Value() T

Value returns the value of the node.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL