package listext

import "github.com/go-playground/pkg/v5/container/list"

Index

Types

type DoublyLinkedList

type DoublyLinkedList[V any] struct {
	// contains filtered or unexported fields
}

DoublyLinkedList is a doubly linked list

func NewDoublyLinked

func NewDoublyLinked[V any]() *DoublyLinkedList[V]

NewDoublyLinked creates a DoublyLinkedList for use.

func (*DoublyLinkedList[V]) Back

func (d *DoublyLinkedList[V]) Back() *Node[V]

Back returns the end/tail element for use without removing it or nil list is empty.

func (*DoublyLinkedList[V]) Clear

func (d *DoublyLinkedList[V]) Clear()

Clear removes all elements from the Linked List.

func (*DoublyLinkedList[V]) Front

func (d *DoublyLinkedList[V]) Front() *Node[V]

Front returns the front/head element for use without removing it or nil list is empty.

func (*DoublyLinkedList[V]) IsEmpty

func (d *DoublyLinkedList[V]) IsEmpty() bool

IsEmpty returns true if the list is empty.

func (*DoublyLinkedList[V]) Len

func (d *DoublyLinkedList[V]) Len() int

Len returns length of the Linked List.

func (*DoublyLinkedList[V]) MoveAfter

func (d *DoublyLinkedList[V]) MoveAfter(node *Node[V], moving *Node[V])

MoveAfter moves the `moving` node after the supplied `node`.

The supplied `node` must be attached to the current list and the `moving` node must either be attached to the current list or not attached to any other otherwise undefined behaviour could occur.

func (*DoublyLinkedList[V]) MoveBefore

func (d *DoublyLinkedList[V]) MoveBefore(node *Node[V], moving *Node[V])

MoveBefore moves the `moving` node before the supplied `node`.

The supplied `node` must be attached to the current list and the `moving` node must either be attached to the current list or not attached to any other otherwise undefined behaviour could occur.

func (*DoublyLinkedList[V]) MoveToBack

func (d *DoublyLinkedList[V]) MoveToBack(node *Node[V])

MoveToBack moves the provided node to the end/tail.

func (*DoublyLinkedList[V]) MoveToFront

func (d *DoublyLinkedList[V]) MoveToFront(node *Node[V])

MoveToFront moves the provided node to the front/head.

func (*DoublyLinkedList[V]) PopBack

func (d *DoublyLinkedList[V]) PopBack() *Node[V]

PopBack removes the last element from a list and returns it or nil.

func (*DoublyLinkedList[V]) PopFront

func (d *DoublyLinkedList[V]) PopFront() *Node[V]

PopFront removes the first element and returns it or nil.

func (*DoublyLinkedList[V]) PushAfter

func (d *DoublyLinkedList[V]) PushAfter(node *Node[V], v V) *Node[V]

PushAfter pushes the supplied value after the supplied node.

The supplied node must be attached to the current list otherwise undefined behaviour could occur.

func (*DoublyLinkedList[V]) PushBack

func (d *DoublyLinkedList[V]) PushBack(v V) *Node[V]

PushBack appends an element to the back of a list.

func (*DoublyLinkedList[V]) PushBefore

func (d *DoublyLinkedList[V]) PushBefore(node *Node[V], v V) *Node[V]

PushBefore pushes the supplied value before the supplied node.

The supplied node must be attached to the current list otherwise undefined behaviour could occur.

func (*DoublyLinkedList[V]) PushFront

func (d *DoublyLinkedList[V]) PushFront(v V) *Node[V]

PushFront adds an element first in the list.

func (*DoublyLinkedList[V]) Remove

func (d *DoublyLinkedList[V]) Remove(node *Node[V])

Remove removes the provided element from the Linked List.

type Node

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

Node is an element of the doubly linked list.

func (*Node[V]) Next

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

Next returns the nodes next value or nil if it is at the tail.

func (*Node[V]) Prev

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

Prev returns the nodes previous value or nil if it is at the head.

func (*Node[V]) Value

func (n *Node[V]) Value() V

Value returns the underlying nodes value.

Source Files

doubly_linked.go

Version
v5.12.0
Published
Feb 18, 2023
Platform
darwin/amd64
Last checked
1 hour ago

Tools for package owners.