Documentation ¶
Index ¶
- func Contains[T comparable](s []T, v T) bool
- func Delete(s []string, toDelete []string) (str []string)
- func Diff(s, t []string) []string
- func Filter[T constraints.Ordered](slice []T, predicateFunc Predicate[T]) []T
- func LeftDiff(s, t []string) []string
- func UnorderedEqual[T constraints.Ordered](a, b []T) bool
- type Predicate
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Contains ¶
func Contains[T comparable](s []T, v T) bool
Contains returns true is the element v is contained in the slice s.
func Diff ¶
Diff checks if s in contained within t and if t is contained within s. Diff returns all elements that are not in the intersection of s and t.
func Filter ¶
func Filter[T constraints.Ordered](slice []T, predicateFunc Predicate[T]) []T
Filter takes a generic slice and a predicate func and returns a slice of all elements in the original slice that satisfy the predicate
func UnorderedEqual ¶
func UnorderedEqual[T constraints.Ordered](a, b []T) bool
UnorderedEqual determines if two slices of the same type contain equal elements ignoring ordering the ordered constraint ensures only ints, floats and strings are usable with this function.
Types ¶
type Predicate ¶
type Predicate[T constraints.Ordered] func(elem T) bool
Predicate defines the expected filter functions Filter accepts
func StartsWithString ¶
StartsWithString returns true if the predicate string starts with the provided prefix