linkedlist

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2022 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 LinkedList

type LinkedList[T comparable] struct {
	// contains filtered or unexported fields
}

LinkedList is the main linked list type.

func New

func New[T comparable]() LinkedList[T]

New is used to create a new linked list.

func (*LinkedList[T]) Clear

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

Clear empties the entire linked list.

func (LinkedList[T]) Contains

func (l LinkedList[T]) Contains(val T) bool

Contains returns true if the value exists in the linked list, false if not.

func (LinkedList[T]) Count

func (l LinkedList[T]) Count() int

Count returns the amount of entries in the linked list.

func (LinkedList[T]) Empty

func (l LinkedList[T]) Empty() bool

Empty returns true if the linked list is empty, false if not.

func (LinkedList[T]) First

func (l LinkedList[T]) First() T

First returns the value at the beginning of the linked list.

func (LinkedList[T]) ForEach

func (l LinkedList[T]) ForEach(f func(i int, val T))

ForEach iterates over the dataset within the linked list, calling the passed function for each value.

func (LinkedList[T]) Get

func (l LinkedList[T]) Get(index int) T

Get gets a value at the specified index.

func (*LinkedList[T]) Insert

func (l *LinkedList[T]) Insert(val T, index int)

Insert inserts a value at the specified index.

func (*LinkedList[T]) InsertFirst

func (l *LinkedList[T]) InsertFirst(val T)

InsertFirst inserts a value at the beginning of the linked list.

func (*LinkedList[T]) InsertLast

func (l *LinkedList[T]) InsertLast(val T)

InsertLast inserts a value at the end of the linked list.

func (LinkedList[T]) Last

func (l LinkedList[T]) Last() T

Last returns the value at the end of the linked list.

func (*LinkedList[T]) Remove

func (l *LinkedList[T]) Remove(index int)

Remove removes a value at the specified index.

func (*LinkedList[T]) RemoveFirst

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

RemoveFirst removes the first value in the linked list.

func (*LinkedList[T]) RemoveLast

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

RemoveLast removes the last value in the linked list.

func (*LinkedList[T]) Update

func (l *LinkedList[T]) Update(index int, val T)

Update updates a value at the specified index.

Jump to

Keyboard shortcuts

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