sliceutil

package
v0.24.2 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2024 License: AGPL-3.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendUnique added in v0.22.0

func AppendUnique[T comparable](vs []T, toAdd T) []T

AppendUnique appends toAdd to the vs slice if toAdd does not already exist in the slice. It returns the new or unchanged slice.

func AppendUniques added in v0.22.0

func AppendUniques[T comparable](vs []T, toAdd []T) []T

AppendUniques appends a slice of values to the vs slice. It only appends values that do not already exist in the slice. It returns the new or unchanged slice.

func Contains added in v0.24.0

func Contains[T comparable](vs []T, t T) bool

Contains returns whether the vs slice contains t.

func Delete added in v0.24.0

func Delete[T comparable](vs []T, toDel T) []T

Delete returns a copy of the vs slice with toDel values removed.

func Exclude added in v0.22.0

func Exclude[T comparable](vs []T, toExclude []T) []T

Exclude returns a copy of the vs slice, excluding all values that are also present in the toExclude slice.

func Filter added in v0.24.0

func Filter[T any](vs []T, f func(T) bool) []T

Filter returns a slice containing the elements of the vs slice that meet the condition specified by f.

func Index added in v0.22.0

func Index[T comparable](vs []T, t T) int

Index returns the first index of the provided value in the provided slice. It returns -1 if it is not found.

func Intersect added in v0.24.0

func Intersect[T comparable](a []T, b []T) []T

Intersect returns a slice containing values that exist in both provided slices.

func Map added in v0.24.0

func Map[T any, V any](vs []T, f func(T) V) []V

Filter returns the result of applying f to each element of the vs slice.

func NotIntersect added in v0.24.0

func NotIntersect[T comparable](a []T, b []T) []T

NotIntersect returns a slice containing values that do not exist in both provided slices.

func SliceSame

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

SliceSame returns true if the two provided slices have equal elements, regardless of order.

func Unique added in v0.24.0

func Unique[T comparable](vs []T) []T

Unique returns a copy of the vs slice, with non-unique values removed.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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