Documentation
¶
Overview ¶
Package slices provides useful functions with slices of any type.
Index ¶
- func Contains[S ~[]E, E comparable](s S, e E) bool
- func Dedup[S ~[]E, E constraints.Ordered](s S) S
- func Diff[S ~[]E, E comparable](s1, s2 S) S
- func Equal[S ~[]E, E comparable](l, r S) bool
- func Intersection[S ~[]E, E comparable](s1, s2 S) S
- func Last[S ~[]E, E any](s S) E
- func Merge[S ~[]E, E comparable](l, r S) S
- func Pretty(s []string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Contains ¶
func Contains[S ~[]E, E comparable](s S, e E) bool
Contains returns true if the given slices s contains k.
func Dedup ¶
func Dedup[S ~[]E, E constraints.Ordered](s S) S
Dedup returns a sorted slice with duplicate entries removed.
func Diff ¶
func Diff[S ~[]E, E comparable](s1, s2 S) S
Diff returns a slice of elements are in s1 but not in s2.
func Equal ¶
func Equal[S ~[]E, E comparable](l, r S) bool
Equal returns true if the slices are the same.
func Intersection ¶
func Intersection[S ~[]E, E comparable](s1, s2 S) S
Intersection returns a slice of elements that are both in s1 and s2. Order matters, the elements from s1 are compared to s2, so the resultant slice will be a subset of s1. If s1 has duplicates entries that intersect, they will be in the result.
func Merge ¶
func Merge[S ~[]E, E comparable](l, r S) S
Merge returns the result of the merged slices.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.