slicer

package
v0.0.0-...-eb2fa4d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 2, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Index

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 Contains

func Contains[T comparable](s []T, e T) bool

Contains returns true if s contains e.

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 Equal

func Equal[T comparable](s1 []T, s2 []T) bool

Equal returns true if s1 and s2 equal.

func Join

func Join[T fmt.Stringer](s []T, sep string) string

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

func RemoveIndex[T any](s []T, i int) []T

RemoveIndex removes element with index i from s. Returns nil, s is nil or empty, or i is not in range.

func Strings

func Strings[T fmt.Stringer](s []T) []string

Strings convert a slice of T to a string slice. If s is nil, returns nil.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL