list

package
v1.1.10 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2025 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Overview

Package list implements a doubly linked list.

To iterate over a list (where l is a *List):

for e := l.Front(); e != nil; e = e.Next() {
	// do something with e.Value
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Element

type Element struct {

	// The value stored with this element.
	Value interface{}
	// contains filtered or unexported fields
}

Element is an element of a linked list.

type List

type List struct {
	// contains filtered or unexported fields
}

List represents a doubly linked list. The zero value for List is an empty list ready to use.

func New

func New() *List

New returns an initialized list.

func (*List) Back

func (l *List) Back() *Element

Back returns the last element of list l or nil if the list is empty.

func (*List) Front

func (l *List) Front() *Element

Front returns the first element of list l or nil if the list is empty.

func (*List) Init

func (l *List) Init() *List

Init initializes or clears list l.

func (*List) Len

func (l *List) Len() int

Len returns the number of elements of list l. The complexity is O(1).

func (*List) MergeBack

func (l *List) MergeBack(l1 *List)

Merge

func (*List) Next

func (l *List) Next(e *Element) *Element

Next returns the next list element or nil.

func (*List) PushBack

func (l *List) PushBack(v interface{}) *Element

PushBack inserts a new element e with value v at the back of list l and returns e.

func (*List) PushFront

func (l *List) PushFront(v interface{}) *Element

PushFront inserts a new element e with value v at the front of list l and returns e.

func (*List) Remove

func (l *List) Remove(e *Element) interface{}

Remove removes e from l if e is an element of list l. It returns the element value e.Value. The element must not be nil.

Jump to

Keyboard shortcuts

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