Documentation ¶
Index ¶
- func AppendIfNotPresent[E any, K comparable](s []E, e E, key func(E) K) ([]E, bool)
- func Equivalent[E any, K comparable](s1, s2 []E, key func(E) K) bool
- func IndexOf[E any, K comparable](s []E, e K, key func(E) K) int
- func Intersect[E any, K comparable](s1, s2 []E, key func(E) K) []E
- func Remove[E any, K comparable](s []E, e E, key func(E) K) ([]E, bool)
- func Union[E any, K comparable](s1, s2 []E, key func(E) K) []E
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 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.