linkedlist

package
v1.6.4 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 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 (ll *LinkedList[T]) Clear()

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

func (*LinkedList[T]) Delete

func (ll *LinkedList[T]) Delete(elm *Element[T])

Delete removes a specific element from the list.

func (*LinkedList[T]) DeleteAtHead

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

DeleteAtHead deletes the element at the head of the list.

func (*LinkedList[T]) DeleteAtTail

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

DeleteAtTail deletes the element at the tail of the list.

func (*LinkedList[T]) InsertAfter

func (ll *LinkedList[T]) InsertAfter(data T, pos *Element[T]) *Element[T]

func (*LinkedList[T]) InsertAtHead

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

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

func (*LinkedList[T]) InsertAtTail

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

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

func (*LinkedList[T]) InsertBefore

func (ll *LinkedList[T]) InsertBefore(data T, pos *Element[T]) *Element[T]

func (*LinkedList[T]) Length

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

Length returns the number of elements in the list.

func (*LinkedList[T]) Values

func (ll *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