xlist

package
v0.15.3 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2024 License: MIT Imports: 0 Imported by: 2 modules, 2 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package xlist contains extensions to the standard library package container/list.

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 doubly-linked list.

func (*List[T]) Back

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

Back returns the node at the back of the list.

func (*List[T]) Clear

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

Clear removes all nodes from the list.

func (*List[T]) Front

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

Front returns the node at the front of the list.

func (*List[T]) InsertAfter

func (l *List[T]) InsertAfter(value T, mark *Node[T]) *Node[T]

InsertBefore adds a new node with the given value after the node mark.

func (*List[T]) InsertBefore

func (l *List[T]) InsertBefore(value T, mark *Node[T]) *Node[T]

InsertBefore adds a new node with the given value before the node mark.

func (*List[T]) Len

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

Len returns the number of items in the list.

func (*List[T]) MoveAfter

func (l *List[T]) MoveAfter(node *Node[T], mark *Node[T])

MoveAfter moves node just after mark. Afterwards, mark.Next() == node && node.Prev() == mark.

func (*List[T]) MoveBefore

func (l *List[T]) MoveBefore(node *Node[T], mark *Node[T])

MoveBefore moves node just before mark. Afterwards, mark.Prev() == node && node.Next() == mark.

func (*List[T]) MoveToBack

func (l *List[T]) MoveToBack(node *Node[T])

MoveToFront moves node to the back of the list.

func (*List[T]) MoveToFront

func (l *List[T]) MoveToFront(node *Node[T])

MoveToFront moves node to the front of the list.

func (*List[T]) PushBack

func (l *List[T]) PushBack(value T) *Node[T]

PushBack adds a new node with the given value to the back of the list.

func (*List[T]) PushFront

func (l *List[T]) PushFront(value T) *Node[T]

PushFront adds a new node with the given value to the front of the list.

func (*List[T]) Remove

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

Remove removes node from the list.

type Node

type Node[T any] struct {

	// Value is user-controlled, and never modified by this package.
	Value T
	// contains filtered or unexported fields
}

Node is a node in a linked-list.

func (*Node[T]) Next

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

Next returns the next node in the list that n is a part of, if there is one.

func (*Node[T]) Prev

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

Prev returns the previous node in the list that n is a part of, if there is one.

Jump to

Keyboard shortcuts

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