list

package
v0.0.0-...-4e8049b Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2025 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Double

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

Double is a doubly-linked list. Unlike Single, nodes of a Double can be removed from the middle of the list rather than only the ends.

func (Double[T]) Nodes

func (ls Double[T]) Nodes() iter.Seq[*DoubleNode[T]]

Nodes returns an iterator over the nodes of the list. It is safe to remove the currently-yielded node from the list during iteration.

func (*Double[T]) Push

func (ls *Double[T]) Push(v T)

Push adds a new node containing v to the tail of the list.

func (*Double[T]) Remove

func (ls *Double[T]) Remove(n *DoubleNode[T])

Remove removes the given node from the list.

type DoubleNode

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

DoubleNode is a node of a Double.

type Single

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

Single is a singly-linked list that also contains a reference to the last node for quick inserts and removals at the head and tail.

func (*Single[T]) All

func (ls *Single[T]) All() iter.Seq[T]

All returns an iterator over the elements of the list.

func (*Single[T]) Enqueue

func (ls *Single[T]) Enqueue(v T)

Enqueue adds v as a new node at the tail of the list.

func (*Single[T]) Peek

func (ls *Single[T]) Peek() (v T)

Peek returns the value of the head node or the zero value if the list is empty.

func (*Single[T]) Pop

func (ls *Single[T]) Pop() bool

Pop removes the current head node from the list. It returns false if the list was already empty.

type SingleNode

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

SingleNode is a node of a Single.

Jump to

Keyboard shortcuts

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