slice

package
v2.10.0 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Chunk

func Chunk[T any](slice []T, chunkSize int) [][]T

Chunk helps chunk a slice into equal size

Types

type ThreadSafe added in v2.9.1

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

ThreadSafe type that can be safely shared between goroutines.

func NewThreadSafe added in v2.9.1

func NewThreadSafe[T any]() *ThreadSafe[T]

NewThreadSafe creates a new lock-free thread-safe slice.

func (*ThreadSafe[T]) Append added in v2.9.1

func (cs *ThreadSafe[T]) Append(item T)

Append adds an item to the concurrent slice.

func (*ThreadSafe[T]) AppendMany added in v2.10.0

func (cs *ThreadSafe[T]) AppendMany(item ...T)

AppendMany adds many items to the concurrent slice

func (*ThreadSafe[T]) Delete added in v2.9.1

func (cs *ThreadSafe[T]) Delete(index int)

Delete an item from the slice

func (*ThreadSafe[T]) Get added in v2.9.1

func (cs *ThreadSafe[T]) Get(index int) (item T)

Get returns the slice item at the given index

func (*ThreadSafe[T]) Items added in v2.9.1

func (cs *ThreadSafe[T]) Items() []T

Items returns the list of items

func (*ThreadSafe[T]) Len added in v2.9.1

func (cs *ThreadSafe[T]) Len() int

Len returns the number of items

func (*ThreadSafe[T]) Reset added in v2.9.1

func (cs *ThreadSafe[T]) Reset()

Reset resets the slice

Jump to

Keyboard shortcuts

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