Documentation ¶
Index ¶
- func AppendUnique[T comparable](s []T, e T) []T
- func AppendUniques[T comparable](s []T, e ...T) []T
- func Contains[T comparable](s []T, e T) bool
- func ContainsDuplicate[T comparable](s []T) bool
- func ContainsN[T comparable](s []T, e T) int
- func Copy[T any](s []T) []T
- func Equal[T comparable](s1 []T, s2 []T) bool
- func Join[T fmt.Stringer](s []T, sep string) string
- func RemoveDuplicates[T comparable](s []T) []T
- func RemoveElem[T comparable](s []T, e T) []T
- func RemoveIndex[T any](s []T, i int) []T
- func Strings[T fmt.Stringer](s []T) []string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendUnique ¶
func AppendUnique[T comparable](s []T, e T) []T
AppendUnique appends e to s if e is not in s. If e is in s, than the returned slice is equal to s, i.e. return the same slice.
func AppendUniques ¶
func AppendUniques[T comparable](s []T, e ...T) []T
AppendUniques appends the elements of e to s if element of e is not in s. If e is nil or empty, returns the same slice.
func ContainsDuplicate ¶
func ContainsDuplicate[T comparable](s []T) bool
ContainsDuplicate returns whether slice s contains any duplicate element.
func ContainsN ¶
func ContainsN[T comparable](s []T, e T) int
ContainsN returns the number of same element e in s.
func Copy ¶
func Copy[T any](s []T) []T
Copy create a copy of s and returns it. If copy fail, returns nil.
func Join ¶
Join join elements of s with sep and return as a string. If s is nil or zero-length, returns an empty string ("").
func RemoveDuplicates ¶
func RemoveDuplicates[T comparable](s []T) []T
RemoveDuplicates removes the duplicate elements from s. The returned slice contains only unique elements.
func RemoveElem ¶
func RemoveElem[T comparable](s []T, e T) []T
RemoveElem removes element e from s.
func RemoveIndex ¶
RemoveIndex removes element with index i from s. Returns nil, s is nil or empty, or i is not in range.
Types ¶
This section is empty.