slice

package
v0.0.0-...-0394936 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Avg

func Avg[T numeric](listOfNumbers []T) T

Avg returns the average of a slice of numeric values

func Contains

func Contains[T comparable](slice []T, e T) bool

func Equal

func Equal[T comparable](a, b []T) bool

func Max

func Max[T numeric](listOfNumbers []T) T

Max returns the maximum value of a numeric slice. If the slice is empty, Max returns 0

func Remove

func Remove[T comparable](s *[]T, elem T)

Remove removes first occurrence of e from slice, but changes the slice, so use only if order doesn't matter!

func RemoveIdx

func RemoveIdx[T comparable](s *[]T, i int)

RemoveFromSlice removes item at index from slice, but changes the slice, so use only if order doesn't matter!

Types

type Rigid

type Rigid[T any, S constraints.Unsigned] struct {
	// contains filtered or unexported fields
}

func NewRigid

func NewRigid[T any, S constraints.Unsigned](size S) *Rigid[T, S]

func NewSafeRigid

func NewSafeRigid[T any, S constraints.Unsigned](size S) *Rigid[T, S]

func (*Rigid[T, S]) Add

func (r *Rigid[T, S]) Add(x ...T) (removed []T)

func (*Rigid[T, S]) Get

func (r *Rigid[T, S]) Get(idx S) *T

func (*Rigid[T, S]) GetAll

func (r *Rigid[T, S]) GetAll() []T

func (*Rigid[T, S]) GetLast

func (r *Rigid[T, S]) GetLast(amount S) []T

func (*Rigid[T, S]) Take

func (r *Rigid[T, S]) Take() []T

type Slice

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

func NewSafeSlice

func NewSafeSlice[T any](capacity int) *Slice[T]

func NewSlice

func NewSlice[T any](capacity int) *Slice[T]

func (*Slice[T]) Add

func (s *Slice[T]) Add(x ...T)

func (*Slice[T]) Clear

func (s *Slice[T]) Clear()

func (*Slice[T]) Commit

func (s *Slice[T]) Commit(fn func(data *[]T, capacity int))

func (*Slice[T]) Get

func (s *Slice[T]) Get(idx int) *T

func (*Slice[T]) GetAll

func (s *Slice[T]) GetAll() []T

func (*Slice[T]) Len

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

func (*Slice[T]) MarshalCBOR

func (s *Slice[T]) MarshalCBOR() ([]byte, error)

func (*Slice[T]) MarshalJSON

func (s *Slice[T]) MarshalJSON() ([]byte, error)

func (*Slice[T]) Take

func (s *Slice[T]) Take() []T

func (*Slice[T]) UnmarshalCBOR

func (s *Slice[T]) UnmarshalCBOR(data []byte) error

func (*Slice[T]) UnmarshalJSON

func (s *Slice[T]) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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