linkedlist

package
v1.0.0-rc-0 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2024 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Element

type Element[T any] struct {
	Data T
	Next *Element[T]
	Prev *Element[T]
}

func NewElement

func NewElement[T any](data T) *Element[T]

type LinkedList

type LinkedList[T any] struct {
	Head *Element[T]
	Tail *Element[T]
	// contains filtered or unexported fields
}

LinkedList represents a doubly linked list.

func New

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

func (*LinkedList[T]) Clear

func (l *LinkedList[T]) Clear()

Clear removes all nodes from the list, making it empty.

func (*LinkedList[T]) Delete

func (l *LinkedList[T]) Delete(ln *Element[T])

Delete removes a specific node from the list.

func (*LinkedList[T]) DeleteAtHead

func (l *LinkedList[T]) DeleteAtHead()

DeleteAtHead deletes the node at the head of the list.

func (*LinkedList[T]) DeleteAtTail

func (l *LinkedList[T]) DeleteAtTail()

DeleteAtTail deletes the node at the tail of the list.

func (*LinkedList[T]) InsertAfter

func (l *LinkedList[T]) InsertAfter(data T, at *Element[T]) *Element[T]

func (*LinkedList[T]) InsertAtHead

func (l *LinkedList[T]) InsertAtHead(data T) *Element[T]

InsertAtHead inserts a new node at the head of the list.

func (*LinkedList[T]) InsertAtTail

func (l *LinkedList[T]) InsertAtTail(data T) *Element[T]

InsertAtTail appends a new node at the tail of the list.

func (*LinkedList[T]) InsertBefore

func (l *LinkedList[T]) InsertBefore(data T, at *Element[T]) *Element[T]

func (*LinkedList[T]) Length

func (l *LinkedList[T]) Length() int

Length returns the number of nodes in the list.

func (*LinkedList[T]) Values

func (l *LinkedList[T]) Values() []T

Values returns a slice of values in the list.

Jump to

Keyboard shortcuts

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