linkedlist

package
v0.0.0-...-24ca9bf Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2022 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNodeNotFound = errors.New("node not found")

Functions

This section is empty.

Types

type LinkedList

type LinkedList[E any] struct {
	// contains filtered or unexported fields
}

LinkedList is a data structure allowing for quick insertion and deletion. Access O(n) Search O(n) * Insert O(1) for known node location -or- O(n) search for node location * Delete O(1) for known node location -or- O(n) search for node location

func (*LinkedList[E]) Delete

func (l *LinkedList[E]) Delete(n Node[E]) error

func (*LinkedList[E]) Head

func (l *LinkedList[E]) Head() Node[E]

func (*LinkedList[E]) InsertAfter

func (l *LinkedList[E]) InsertAfter(parent *node[E], new *node[E])

func (*LinkedList[E]) InsertBefore

func (l *LinkedList[E]) InsertBefore(parent *node[E], new *node[E])

func (*LinkedList[E]) Len

func (l *LinkedList[E]) Len() int

func (*LinkedList[E]) Tail

func (l *LinkedList[E]) Tail() Node[E]

type LinkedLister

type LinkedLister[E any] interface {
	Head() node[E]
	Tail() node[E]
	InsertBefore(parent *node[E], new *node[E])
	InsertAfter(parent *node[E], new *node[E])
	Delete(n *node[E]) error
	Len() int
}

LinkedLister is a data structure allowing for quick insertion and deletion. Access O(n) Search O(n) * Insert O(1) for known node location -or- O(n) search for node location * Delete O(1) for known node location -or- O(n) search for node location

type Node

type Node[E any] interface {
	Data() *E
	Next() Node[E]
	Prev() Node[E]

	Connect(first, second Node[E])
	// Remove(n Node[E])
	InsertBetween(first, second Node[E])

	SetData(data *E)
	SetNext(Node[E])
	SetPrev(Node[E])

	Clear()
}

LinkedList is a data structure allowing for quick insertion and deletion. Access O(n) Search O(n) * Insert O(1) for known node location -or- O(n) search for node location * Delete O(1) for known node location -or- O(n) search for node location

func NewNode

func NewNode[E any, N *node[E]](data *E, next Node[E]) Node[E]

NewNode returns a new Node object containing the data and pointer arguments.

Jump to

Keyboard shortcuts

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