gslice

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package gslice Author: hyphen Copyright 2023 hyphen. All rights reserved. Create-time: 2023/12/4

Index

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 DeepCopy added in v0.3.0

func DeepCopy[T any, S ~[]T](s S) S

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 Filter

func Filter[F any](s []F, fc func(F) bool) []F

func FilterMap added in v0.3.0

func FilterMap[F, T any](s []F, fc func(F) (T, bool)) []T

func Find added in v0.3.0

func Find[T any](s []T, f func(T) bool) (T, bool)

func FindRev added in v0.3.0

func FindRev[T any](s []T, f func(T) bool) (T, bool)

func Fold added in v0.3.0

func Fold[T1, T2 any](s []T1, fc func(T2, T1) T2, init T2) T2

func ForEach

func ForEach[T any](s []T, fc func(T))

func ForEachIdx

func ForEachIdx[T any](s []T, fc func(int, T))

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 Map

func Map[F, T any](s []F, fc func(F) T) []T

func Reduce added in v0.3.0

func Reduce[T any](s []T, fc func(T, T) T) (T, bool)

func Reject added in v0.3.0

func Reject[T any](s []T, fc func(T) bool) []T

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

func TryMap

func TryMap[F, T any](s []F, fc func(F) (T, error)) ([]T, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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