Documentation
¶
Overview ¶
Package slices defines various functions useful with slices of any type.
Index ¶
- func Clone[S ~[]E, E any](s S) S
- func Contains[S ~[]E, E comparable](s S, v E) bool
- func ContainsFunc[S ~[]E, E any](s S, f func(E) bool) bool
- func Diff[S ~[]E, E comparable](s1, s2 S) S
- func Index[S ~[]E, E comparable](s S, v E) int
- func IndexFunc[S ~[]E, E any](s S, f func(E) bool) int
- func Intersect[S ~[]E, E comparable](s1, s2 S) S
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Clone ¶
func Clone[S ~[]E, E any](s S) S
Clone returns a copy of the slice. The elements are copied using assignment, so this is a shallow clone.
func Contains ¶
func Contains[S ~[]E, E comparable](s S, v E) bool
Contains reports whether v is present in s.
func ContainsFunc ¶
ContainsFunc reports whether at least one element e of s satisfies f(e).
func Diff ¶
func Diff[S ~[]E, E comparable](s1, s2 S) S
Diff return the difference set of s1 and s2, that is, the set of all elements that belong to s1 but not s2.
func Index ¶
func Index[S ~[]E, E comparable](s S, v E) int
Index returns the index of the first occurrence of v in s, or -1 if not present.
func Intersect ¶
func Intersect[S ~[]E, E comparable](s1, s2 S) S
Intersect return the intersection set of s1 and s2, that is, the set of all elements that belong to both s1 and s2.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.