list

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2025 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Overview

Package list is a generic and thus type-safe version of golang's container/list. Wherever possible, it mimics the exact internal behavior as closely as possible.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Element

type Element[E any] struct {

	// Value is the value of the list Element.
	Value E
	// contains filtered or unexported fields
}

Element is an element of a List.

func (*Element[E]) Next

func (e *Element[E]) Next() *Element[E]

Next returns the next Element in the List, if any.

func (*Element[E]) Prev

func (e *Element[E]) Prev() *Element[E]

Prev returns the previous Element in the List, if any.

type List

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

List is a doubly-linked list.

func New

func New[E any]() *List[E]

New constructs a new empty List.

func (*List[E]) Back

func (l *List[E]) Back() *Element[E]

Back returns the Element at the back of the list, if any.

func (*List[E]) Front

func (l *List[E]) Front() *Element[E]

Front returns the Element at the front of the list, if any.

func (*List[E]) Init

func (l *List[E]) Init() *List[E]

Init initializes the list and pointers of the list.

func (*List[E]) InsertAfter

func (l *List[E]) InsertAfter(e E, mark *Element[E]) *Element[E]

InsertAfter inserts the value after the Element used as mark, if the Element is part of the list.

func (*List[E]) InsertBefore

func (l *List[E]) InsertBefore(e E, mark *Element[E]) *Element[E]

InsertBefore inserts the value before the Element used as mark, if the Element is part of the list.

func (*List[E]) Len

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

Len returns the number of Elements in the list.

func (*List[E]) MoveAfter

func (l *List[E]) MoveAfter(e, mark *Element[E])

MoveAfter moves the Element after the marked element if it is part of the List.

func (*List[E]) MoveBefore

func (l *List[E]) MoveBefore(e, mark *Element[E])

MoveBefore moves the Element before the marked element if it is part of the List.

func (*List[E]) MoveToBack

func (l *List[E]) MoveToBack(e *Element[E])

MoveToBack moves the Element to the back of the List if it is part of it.

func (*List[E]) MoveToFront

func (l *List[E]) MoveToFront(e *Element[E])

MoveToFront moves the Element to the front of the List if it is part of it.

func (*List[E]) PushBack

func (l *List[E]) PushBack(e E) *Element[E]

PushBack inserts the value at the back of the list, returning the created Element.

func (*List[E]) PushBackList

func (l *List[E]) PushBackList(other *List[E])

PushBackList pushes all values of the other list to the back of this List.

func (*List[E]) PushFront

func (l *List[E]) PushFront(e E) *Element[E]

PushFront inserts the value at the front of the list, returning the created Element.

func (*List[E]) PushFrontList

func (l *List[E]) PushFrontList(other *List[E])

PushFrontList pushes all values of the other list to the front of this List.

func (*List[E]) Remove

func (l *List[E]) Remove(e *Element[E]) E

Remove removes the Element from the list if it was part of the List.

Jump to

Keyboard shortcuts

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