Documentation
¶
Overview ¶
Package slices provides generic slice utility functions.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Difference ¶ added in v1.1.0
func Difference[S []E, E comparable](a, b S) S
Difference returns all the elements in 'a' that are not in 'b'.
NOTE: The provided slices may contain duplicates but the returned slice will not.
func Filter ¶
Filter removes all elements in the given slice that do not match the given predicates.
NOTE: Providing no predicates results in a no-op.
func Intersection ¶ added in v1.1.0
func Intersection[S []E, E comparable](a, b S) S
Intersection returns all the elements that are in both 'a' and 'b'.
NOTE: The provided slices may contain duplicates but the returned slice will not.
func Subset ¶
func Subset[S []E, E comparable](a, b S) bool
Subset returns a boolean indicating whether a, is a subset of b.
NOTE: Returns true if a has zero elements since an empty set is a subset of all sets.
func Sum ¶
func Sum[S []E, E constraints.Ordered](s S) E
Sum returns the summation of the elements in the provided slice.
func Union ¶
func Union[S []E, E comparable](a, b S) S
Union returns all the elements that are in either 'a' or 'b'.
NOTE: The provided slices may contain duplicates but the returned slice will not.
Types ¶
This section is empty.