slice

package
v2.8.1 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: MIT Imports: 2 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 Safe added in v2.6.2

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

Safe type that can be safely shared between goroutines.

func NewSafe added in v2.7.0

func NewSafe[T any]() *Safe[T]

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

func (*Safe[T]) Append added in v2.6.2

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

Append adds an item to the concurrent slice.

func (*Safe[T]) Delete added in v2.6.2

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

Delete an item from the slice

func (*Safe[T]) Get added in v2.6.2

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

Get returns the slice item at the given index

func (*Safe[T]) Items added in v2.6.2

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

Items returns the list of items

func (*Safe[T]) Len added in v2.6.2

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

Len returns the number of items

func (*Safe[T]) Reset added in v2.6.2

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

Reset resets the slice

Jump to

Keyboard shortcuts

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