slices

package
v0.17.0-m0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2023 License: Apache-2.0 Imports: 1 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendIfNotPresent

func AppendIfNotPresent[E any, K comparable](s []E, e E, key func(E) K) ([]E, bool)

AppendIfNotPresent appends element e to s if not already present using the given key function. Returns the resultant slice and a bool indicating if the element was added.

func Equivalent

func Equivalent[E any, K comparable](s1, s2 []E, key func(E) K) bool

Equivalent reports whether two slices contain the same elements regardless of order and uniqueness.

func IndexOf

func IndexOf[E any, K comparable](s []E, e K, key func(E) K) int

IndexOf returns the index of the first occurrence of element e in s using the given key function, or -1 if not present.

func Intersect

func Intersect[E any, K comparable](s1, s2 []E, key func(E) K) []E

Intersect returns the intersection of two slices using the given key function. The returned intersection preserves the order of elements in s2.

func Key added in v0.17.0

func Key[K comparable](k K) K

func Remove

func Remove[E any, K comparable](s []E, e E, key func(E) K) ([]E, bool)

Remove the first instance of element e from s using the given key function. Returns the resultant slice and a bool indicating if the element was removed.

func Union

func Union[E any, K comparable](s1, s2 []E, key func(E) K) []E

Union returns the union of two slices using the given key function.

Types

This section is empty.

Jump to

Keyboard shortcuts

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