xlist

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2022 License: MIT Imports: 0 Imported by: 2

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]

PushFront 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