unilist

package
v0.0.0-...-9e67e2f Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2024 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 List

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

Unidirectional(Singly) Linked List

func New

func New[T any]() *List[T]

func (*List[T]) Clear

func (list *List[T]) Clear()

Clears the list

func (*List[T]) Head

func (list *List[T]) Head() *Node[T]

func (*List[T]) InsertAfter

func (list *List[T]) InsertAfter(val T, node *Node[T]) *Node[T]

Inserts a new node after the given node

func (*List[T]) Len

func (list *List[T]) Len() int

func (*List[T]) PopFront

func (list *List[T]) PopFront() *Node[T]

Deletes head

func (*List[T]) PushBack

func (list *List[T]) PushBack(val T)

Appends a new node as a new tail

func (*List[T]) PushFront

func (list *List[T]) PushFront(val T)

Inserts a new node as a new head

func (*List[T]) Remove

func (list *List[T]) Remove(prev, node *Node[T]) *Node[T]

Removes the given node prev MUST be right before the node, otherwise list.len will miscount

func (*List[T]) SetHead

func (list *List[T]) SetHead(prev, node *Node[T])

Sets the given node as a new head

func (*List[T]) SetTail

func (list *List[T]) SetTail(prev, node *Node[T])

Sets the given node as a new tail

func (*List[T]) String

func (list *List[T]) String() string

Stringifies the list

func (*List[T]) Tail

func (list *List[T]) Tail() *Node[T]

type Node

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

List Node

func (*Node[T]) Next

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

Jump to

Keyboard shortcuts

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