doublylinkedlist

package
v4.0.0-...-ae7b6de Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2023 License: GPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type List

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

List is a generic doubly-linked list whose nodes can store any data type. It allows retrieving pointers to the first and last nodes.

func (*List[T]) Append

func (l *List[T]) Append(n *Node[T])

Append adds the passed in node to the end of the list.

func (*List[T]) Copy

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

Copy returns a copy of the origina list.

func (*List[T]) First

func (l *List[T]) First() *Node[T]

First gets the reference to the first node in the list.

func (*List[T]) Last

func (l *List[T]) Last() *Node[T]

Last gets the reference to the last node in the list.

func (*List[T]) Len

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

Len gets the length of the list.

func (*List[T]) Remove

func (l *List[T]) Remove(n *Node[T])

Remove removes the passed in node from the list.

type Node

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

Node is a generic data structure that contains three fields: references to the previous and to the next node in the list, and one data field.

func NewNode

func NewNode[T any](value T) *Node[T]

NewNode creates a new node with the passed in value.

func (*Node[T]) Copy

func (n *Node[T]) Copy() *Node[T]

Copy copies the given node and returns a new one. It does not do a deep copy of T.

func (*Node[T]) Next

func (n *Node[T]) Next() (*Node[T], error)

Next gets the node's successor node.

func (*Node[T]) Prev

func (n *Node[T]) Prev() (*Node[T], error)

Prev gets the node's predecessor node.

func (*Node[T]) Value

func (n *Node[T]) Value() (T, error)

Value gets the value stored in the node.

Jump to

Keyboard shortcuts

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