slice

package
v2.6.1 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 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 Item

type Item[T any] struct {
	Index int
	Value T
}

Item represents the slice item

type Slice

type Slice[T any] struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Slice type that can be safely shared between goroutines.

func New

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

New creates a new synchronized slice.

func (*Slice[T]) Append

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

Append adds an item to the concurrent slice.

func (*Slice[T]) Delete

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

Delete an item from the slice

func (*Slice[T]) Get

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

Get returns the slice item at the given index

func (*Slice[T]) Items

func (cs *Slice[T]) Items() []Item[T]

Items returns the list of items

func (*Slice[T]) Len

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

Len returns the number of items

func (*Slice[T]) Reset

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

Jump to

Keyboard shortcuts

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