synclist

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Iterator

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

Iterator is an iterator over the elements in a List.

func (*Iterator[T]) Get

func (it *Iterator[T]) Get() T

Get returns the element at the current position.

func (*Iterator[T]) Move

func (it *Iterator[T]) Move()

Move moves the iterator to the next element.

func (*Iterator[T]) Valid

func (it *Iterator[T]) Valid() bool

Valid returns true if the iterator is positioned at a valid element.

type List

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

List is a lock-free singly linked list. It is safe to use it concurrently from multiple goroutines. The zero value is ready to use. Do not copy a non-zero List.

func New

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

New creates an empty List.

func NewFromIterable added in v1.6.1

func NewFromIterable[T any](iterable iter.Iterable[T]) *List[T]

NewFromIterable creates a List from the specified iter.Iterable in reverse order. List.Reverse can be used to restore the original order.

func (*List[T]) Clear

func (list *List[T]) Clear()

Clear removes all elements from the List.

func (*List[T]) Head

func (list *List[T]) Head() *Node[T]

Head returns the first element in the List.

func (*List[T]) Iterator

func (list *List[T]) Iterator() iter.Iterator[T]

Iterator returns an iterator over the elements in the List.

func (*List[T]) Prepend

func (list *List[T]) Prepend(value T)

Prepend adds the specified value to the beginning of the List.

func (*List[T]) Reverse

func (list *List[T]) Reverse()

Reverse reverses the order of the elements in the List. This method is not thread-safe. It is meant to be used after all concurrent operations on the List have finished.

func (*List[T]) Stream

func (list *List[T]) Stream(yield func(T) bool)

Stream streams the elements of the List.

type Node

type Node[T any] struct {
	Value T // The value stored in the node.
	// contains filtered or unexported fields
}

Node is a node in a singly linked list.

func (Node[T]) Next

func (node Node[T]) Next() *Node[T]

Next returns the next node in the list.

Jump to

Keyboard shortcuts

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