Documentation
¶
Overview ¶
Package gslice Author: hyphen Copyright 2023 hyphen. All rights reserved. Create-time: 2023/12/4
Index ¶
- func Contains[T comparable](s []T, v T) bool
- func ContainsAll[T comparable](s []T, vs ...T) bool
- func ContainsAny[T comparable](s []T, vs ...T) bool
- func DeepCopy[T any, S ~[]T](s S) S
- func Distinct[T comparable](s []T) []T
- func DistinctBy[K comparable, V any](s []V, fc func(V) K) []V
- func Filter[F any](s []F, fc func(F) bool) []F
- func FilterMap[F, T any](s []F, fc func(F) (T, bool)) []T
- func Find[T any](s []T, f func(T) bool) (T, bool)
- func FindRev[T any](s []T, f func(T) bool) (T, bool)
- func Fold[T1, T2 any](s []T1, fc func(T2, T1) T2, init T2) T2
- func ForEach[T any](s []T, fc func(T))
- func ForEachIdx[T any](s []T, fc func(int, T))
- func GroupBy[K comparable, T any, S ~[]T](s S, f func(T) K) map[K]S
- func Map[F, T any](s []F, fc func(F) T) []T
- func Reduce[T any](s []T, fc func(T, T) T) (T, bool)
- func Reject[T any](s []T, fc func(T) bool) []T
- func Remove[T comparable](s []T, v T) []T
- func RemoveN[T comparable](s []T, v T, n int) []T
- func ToMap[F, V any, K comparable](s []F, fc func(F) (K, V)) map[K]V
- func TryMap[F, T any](s []F, fc func(F) (T, error)) ([]T, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Contains ¶ added in v0.3.0
func Contains[T comparable](s []T, v T) bool
func ContainsAll ¶ added in v0.3.0
func ContainsAll[T comparable](s []T, vs ...T) bool
func ContainsAny ¶ added in v0.3.0
func ContainsAny[T comparable](s []T, vs ...T) bool
func Distinct ¶ added in v0.3.0
func Distinct[T comparable](s []T) []T
func DistinctBy ¶ added in v0.3.0
func DistinctBy[K comparable, V any](s []V, fc func(V) K) []V
func ForEachIdx ¶
func GroupBy ¶ added in v0.3.0
func GroupBy[K comparable, T any, S ~[]T](s S, f func(T) K) map[K]S
func Remove ¶ added in v0.3.0
func Remove[T comparable](s []T, v T) []T
func RemoveN ¶ added in v0.3.0
func RemoveN[T comparable](s []T, v T, n int) []T
func ToMap ¶
func ToMap[F, V any, K comparable](s []F, fc func(F) (K, V)) map[K]V
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.