list

package
v0.0.0-...-bb1cfd0 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2026 License: Apache-2.0 Imports: 1 Imported by: 1

README

Package cloudeng.io/algo/container/list

import cloudeng.io/algo/container/list

Types

Type Double
type Double[T any] struct {
	// contains filtered or unexported fields
}

Double provides a doubly linked list.

Functions
func NewDouble[T any]() *Double[T]
Methods
func (dl *Double[T]) Append(val T) DoubleID[T]
func (dl *Double[T]) Forward() iter.Seq[T]
func (dl *Double[T]) Head() T
func (dl *Double[T]) Len() int
func (dl *Double[T]) Prepend(val T) DoubleID[T]
func (dl *Double[T]) Remove(val T, cmp func(a, b T) bool)
func (dl *Double[T]) RemoveItem(id DoubleID[T])
func (dl *Double[T]) RemoveReverse(val T, cmp func(a, b T) bool)
func (dl *Double[T]) Reset()
func (dl *Double[T]) Reverse() iter.Seq[T]
func (dl *Double[T]) Tail() T
Type DoubleID
type DoubleID[T any] *doubleItem[T]
Type Single
type Single[T any] struct {
	// contains filtered or unexported fields
}

Single provides a singly linked list.

Functions
func NewSingle[T any]() *Single[T]

NewSingle creates a new instance of Single[T] with an initial empty state.

Methods
func (sl *Single[T]) Append(val T) SingleID[T]

Append adds a new item to the end of the list and returns its ID.

func (sl *Single[T]) Forward() iter.Seq[T]

Forward returns an iterator over the list.

func (sl *Single[T]) Head() T

Head returns the first item in the list.

func (sl *Single[T]) Len() int

Len returns the number of items in the singly linked list.

func (sl *Single[T]) Prepend(val T) SingleID[T]

Prepend adds a new item to the beginning of the list and returns its ID.

func (sl *Single[T]) Remove(val T, cmp func(a, b T) bool)

Remove removes the first occurrence of the specified value from the list.

func (sl *Single[T]) RemoveItem(id SingleID[T])

RemoveItem removes the item with the specified ID from the list.

func (sl *Single[T]) Reset()

Reset resets the singly linked list to its initial empty state.

Type SingleID
type SingleID[T any] *singleItem[T]

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Double

type Double[T any] struct {
	// contains filtered or unexported fields
}

Double provides a doubly linked list.

func NewDouble

func NewDouble[T any]() *Double[T]

func (*Double[T]) Append

func (dl *Double[T]) Append(val T) DoubleID[T]

func (*Double[T]) Forward

func (dl *Double[T]) Forward() iter.Seq[T]

func (*Double[T]) Head

func (dl *Double[T]) Head() T

func (*Double[T]) Len

func (dl *Double[T]) Len() int

func (*Double[T]) Prepend

func (dl *Double[T]) Prepend(val T) DoubleID[T]

func (*Double[T]) Remove

func (dl *Double[T]) Remove(val T, cmp func(a, b T) bool)

func (*Double[T]) RemoveItem

func (dl *Double[T]) RemoveItem(id DoubleID[T])

func (*Double[T]) RemoveReverse

func (dl *Double[T]) RemoveReverse(val T, cmp func(a, b T) bool)

func (*Double[T]) Reset

func (dl *Double[T]) Reset()

func (*Double[T]) Reverse

func (dl *Double[T]) Reverse() iter.Seq[T]

func (*Double[T]) Tail

func (dl *Double[T]) Tail() T

type DoubleID

type DoubleID[T any] *doubleItem[T]

type Single

type Single[T any] struct {
	// contains filtered or unexported fields
}

Single provides a singly linked list.

func NewSingle

func NewSingle[T any]() *Single[T]

NewSingle creates a new instance of Single[T] with an initial empty state.

func (*Single[T]) Append

func (sl *Single[T]) Append(val T) SingleID[T]

Append adds a new item to the end of the list and returns its ID.

func (*Single[T]) Forward

func (sl *Single[T]) Forward() iter.Seq[T]

Forward returns an iterator over the list.

func (*Single[T]) Head

func (sl *Single[T]) Head() T

Head returns the first item in the list.

func (*Single[T]) Len

func (sl *Single[T]) Len() int

Len returns the number of items in the singly linked list.

func (*Single[T]) Prepend

func (sl *Single[T]) Prepend(val T) SingleID[T]

Prepend adds a new item to the beginning of the list and returns its ID.

func (*Single[T]) Remove

func (sl *Single[T]) Remove(val T, cmp func(a, b T) bool)

Remove removes the first occurrence of the specified value from the list.

func (*Single[T]) RemoveItem

func (sl *Single[T]) RemoveItem(id SingleID[T])

RemoveItem removes the item with the specified ID from the list.

func (*Single[T]) Reset

func (sl *Single[T]) Reset()

Reset resets the singly linked list to its initial empty state.

type SingleID

type SingleID[T any] *singleItem[T]

Jump to

Keyboard shortcuts

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