linkedlist

package
v0.0.0-...-ec0d933 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2025 License: MIT Imports: 3 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 {
	// contains filtered or unexported fields
}

func (*Element[T]) Next

func (e *Element[T]) Next() *Element[T]

func (*Element[T]) Previous

func (e *Element[T]) Previous() *Element[T]

func (*Element[T]) Remove

func (e *Element[T]) Remove()

func (*Element[T]) Value

func (e *Element[T]) Value() T

type List

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

func New

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

func (*List[T]) Add

func (l *List[T]) Add(data T) *Element[T]

AddLast adds elements to the tail of the linked list, O(1)

func (*List[T]) AddAt

func (l *List[T]) AddAt(index int, data T) error

AddAt adds an element at a specified index

func (*List[T]) AddFirst

func (l *List[T]) AddFirst(data T) *Element[T]

AddFirst adds elements to the beginning (head) of this linked list, O(1)

func (*List[T]) Clear

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

Clear empty this linked list, O(1)

func (*List[T]) Clone

func (l *List[T]) Clone() *List[T]

func (*List[T]) Delete

func (l *List[T]) Delete(fn func(T) bool) bool

Delete removes a particular value in the linked list, O(n)

func (*List[T]) DeleteAt

func (l *List[T]) DeleteAt(index int) (T, error)

DeleteAt removes a element at a particular index, O(n)

func (*List[T]) Entries

func (l *List[T]) Entries() iter.Seq2[int, T]

func (*List[T]) Get

func (l *List[T]) Get(index int) (T, error)

func (*List[T]) Head

func (l *List[T]) Head() *Element[T]

func (*List[T]) MoveToFirst

func (l *List[T]) MoveToFirst(e *Element[T])

MoveToFirst moves element to the beginning (head) of this linked list, O(1)

func (*List[T]) MoveToLast

func (l *List[T]) MoveToLast(e *Element[T])

MoveToLast moves element to the tail of the linked list, O(1)

func (*List[T]) PeekFirst

func (l *List[T]) PeekFirst() (T, error)

PeekFirst checks the value of the first element (head) if it exists, O(1)

func (*List[T]) PeekLast

func (l *List[T]) PeekLast() (T, error)

PeekLast checks the value of the last element (tail) if it exists, O(1)

func (*List[T]) RemoveFirst

func (l *List[T]) RemoveFirst() (T, error)

RemoveFirst removes the first value at the head of the linked list, O(1)

func (*List[T]) RemoveLast

func (l *List[T]) RemoveLast() (T, error)

RemoveLast removes the last value at the tail of the linked list, O(1)

func (*List[T]) ReplaceAll

func (l *List[T]) ReplaceAll(fn func(int, T) T)

func (*List[T]) Set

func (l *List[T]) Set(index int, data T) error

AddAt adds an element at a specified index

func (*List[T]) Size

func (l *List[T]) Size() int

Size returns the size of this linked list

func (*List[T]) Tail

func (l *List[T]) Tail() *Element[T]

func (*List[T]) Values

func (l *List[T]) Values() iter.Seq[T]

Jump to

Keyboard shortcuts

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