list

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2026 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

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
}

func New

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

New creates a linked list of entries.

func (*List[T]) Back

func (l *List[T]) Back() *ListEntry[T]

Back returns the last entry in the list if there is an entry, else nil.

func (*List[T]) Front

func (l *List[T]) Front() *ListEntry[T]

Front returns the first entry in the list if there is an entry, else nil.

func (*List[T]) IterateEntries

func (l *List[T]) IterateEntries(fn func(*ListEntry[T]) bool) bool

IterateEntries will call fn for each entry in the list, starting from the front. If fn returns false the iteration terminates and Iterate will return false, else it will return true. It is safe to remove the entry passed to fn.

func (*List[T]) IterateValues

func (l *List[T]) IterateValues(fn func(T) bool) bool

IterateValues will call fn for each entry in the list, starting from the front. If fn returns false the iteration terminates and IterateValues will return false, else it will return true. It is safe to remove the entry corresponding to the value passed to fn.

func (*List[T]) Length

func (l *List[T]) Length() uint

Length returns the number of entries in the list.

func (*List[T]) PushBack

func (l *List[T]) PushBack(value T) *ListEntry[T]

PushBack adds/moves the value to the back of the list. It returns the list entry.

func (*List[T]) PushFront

func (l *List[T]) PushFront(value T) *ListEntry[T]

PushFont adds/moves the value to the front of the list. It returns the list entry.

type ListEntry

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

func (*ListEntry[T]) Next

func (e *ListEntry[T]) Next() *ListEntry[T]

Next returns the next entry in the list after the specified entry if there is a next entry, else it returns nil.

func (*ListEntry[T]) Previous

func (e *ListEntry[T]) Previous() *ListEntry[T]

Previous returns the previous entry in the list before the specified if there is a previous entry, else it returns nil.

func (*ListEntry[T]) Remove

func (e *ListEntry[T]) Remove()

Remove removes the entry from the list it belongs to.

func (*ListEntry[T]) Value

func (e *ListEntry[T]) Value() T

Value returns the value for the entry.

type UniqueList

type UniqueList[T comparable] struct {
	// contains filtered or unexported fields
}

func NewUnique

func NewUnique[T comparable]() *UniqueList[T]

NewUnique creates a linked list of unique entries.

func (*UniqueList[T]) Back

func (l *UniqueList[T]) Back() *UniqueListEntry[T]

Back returns the last entry in the list if there is an entry, else nil.

func (*UniqueList[T]) Front

func (l *UniqueList[T]) Front() *UniqueListEntry[T]

Front returns the first entry in the list if there is an entry, else nil.

func (*UniqueList[T]) Get

func (l *UniqueList[T]) Get(value T) *UniqueListEntry[T]

Get returns the list entry for the specified value if present, else nil.

func (*UniqueList[T]) IterateEntries

func (l *UniqueList[T]) IterateEntries(fn func(*UniqueListEntry[T]) bool) bool

IterateEntries will call fn for each entry in the list, starting from the front. If fn returns false the iteration terminates and IterateEntries will return false, else it will return true. It is safe to remove the entry passed to fn.

func (*UniqueList[T]) IterateValues

func (l *UniqueList[T]) IterateValues(fn func(T) bool) bool

IterateValues will call fn for each entry in the list, starting from the front. If fn returns false the iteration terminates and IterateValues will return false, else it will return true. It is safe to remove the entry corresponding to the value passed to fn.

func (*UniqueList[T]) Length

func (l *UniqueList[T]) Length() uint

Length returns the number of entries in the list.

func (*UniqueList[T]) PushBack

func (l *UniqueList[T]) PushBack(value T) *UniqueListEntry[T]

PushBack adds/moves the value to the back of the list. It returns the list entry.

func (*UniqueList[T]) PushFront

func (l *UniqueList[T]) PushFront(value T) *UniqueListEntry[T]

PushFont adds/moves the value to the front of the list. It returns the list entry.

func (*UniqueList[T]) Remove

func (l *UniqueList[T]) Remove(value T)

Remove removes the entry with the corresponding value from the list.

type UniqueListEntry

type UniqueListEntry[T comparable] struct {
	// contains filtered or unexported fields
}

func (*UniqueListEntry[T]) Next

func (e *UniqueListEntry[T]) Next() *UniqueListEntry[T]

Next returns the next entry in the list after the specified entry if there is a next entry, else it returns nil.

func (*UniqueListEntry[T]) Previous

func (e *UniqueListEntry[T]) Previous() *UniqueListEntry[T]

Previous returns the previous entry in the list before the specified if there is a previous entry, else it returns nil.

func (*UniqueListEntry[T]) Remove

func (e *UniqueListEntry[T]) Remove()

Remove removes the entry from the list it belongs to.

func (*UniqueListEntry[T]) Value

func (e *UniqueListEntry[T]) Value() T

Value returns the value for the entry.

Jump to

Keyboard shortcuts

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