Documentation
¶
Index ¶
- Variables
- func CopyFilter[T any](l []T, f func(T) bool) []T
- func Distinct(l []string) []string
- func DistinctFunc() func([]string) []string
- func FastDistinct(l []string) []string
- func Filter[T any](l []T, f func(T) bool) []T
- func FilterEmptyStrFunc() func([]string) []string
- func FilterFunc[T any](f func(T) bool) func([]T) []T
- func MapFunc[T any, V any](mapFunc func(t T) V) func([]T) []V
- func MapTo[T any, V any](ts []T, mapFunc func(t T) V) []V
- func MergeMap[K comparable, V any](vs []V, keyFunc func(v V) K) map[K]V
- func MergeMapAs[T any, K comparable, V any](ts []T, keyFunc func(t T) K, valueFunc func(t T) V) map[K]V
- func MergeMapSlice[K comparable, V any](vs []V, keyFunc func(v V) K) map[K][]V
- func NewSyncSlice[T any](cap int) *syncSlice[T]
- func QuoteStrSlice(sl []string) []string
- func SliceCopy[T any](v []T) []T
- func SliceFilterFirst[T any](items []T, f func(T) bool) (T, bool)
- func SliceFirst[T any](v []T) (t T, ok bool)
- func SliceGetOne[T any](items []*T) *T
- func SliceRemove[T any](v []T, idx ...int) []T
- func SplitSubSlices[T any](sl []T, limit int, f func(sub []T) error) error
- func Transform[T any, V any](sl []T, f func([]T) []V, fs ...func([]V) []V) []V
- func Update[T any](sl []T, fs ...func([]T) []T) []T
- func UpdateSliceValue[T any](s []T, upd func(t T) T)
- func UpdateTransform[T any, V any](sl []T, f func([]T) []V, fs ...func([]T) []T) []V
Constants ¶
This section is empty.
Variables ¶
View Source
var (
FilterEmptyStr = FilterEmptyStrFunc
)
Functions ¶
func FastDistinct ¶
Filter duplicate values, faster but values are sorted, and the slice values are filtered in place.
func Filter ¶
Filter slice values in place.
Be cautious that both slices are backed by the same array.
func FilterEmptyStrFunc ¶ added in v0.3.0
func MergeMap ¶
func MergeMap[K comparable, V any](vs []V, keyFunc func(v V) K) map[K]V
Merge slice of items to a map.
func MergeMapAs ¶
func MergeMapAs[T any, K comparable, V any](ts []T, keyFunc func(t T) K, valueFunc func(t T) V) map[K]V
Merge slice of items to a map.
func MergeMapSlice ¶
func MergeMapSlice[K comparable, V any](vs []V, keyFunc func(v V) K) map[K][]V
Merge slice of items to a map.
func NewSyncSlice ¶
func QuoteStrSlice ¶
func SliceFilterFirst ¶
Select one from the slice that matches the condition.
func SliceFirst ¶
func SliceRemove ¶
func UpdateSliceValue ¶
func UpdateSliceValue[T any](s []T, upd func(t T) T)
func UpdateTransform ¶ added in v0.3.0
Update slice values then transform value to another type.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.