lists

package
v0.0.0-...-d05e8a6 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2022 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func All

func All[T any](l []T, pred func(T) bool) bool

All 判断列表中的所有元素是否都满足pred函数

func Any

func Any[T any](l []T, pred func(T) bool) bool

Any 判断列表中是否存在元素满足pred函数

func Copy

func Copy[T any](l []T) []T

Copy 拷贝列表

func Difference

func Difference[T constraints.Ordered](l1, l2 []T) []T

Difference 返回两个列表的差集

func Filter

func Filter[T any](l []T, pred func(T) bool) []T

Filter 过滤掉列表中不满足pred函数的元素

func FilterMap

func FilterMap[T1, T2 any](l []T1, fun func(T1) (T2, bool)) []T2

FilterMap 过滤列表并映射

func Insert

func Insert[T constraints.Ordered](l []T, v T) ([]T, bool)

Insert 元素不存在时插入

func Intersection

func Intersection[T constraints.Ordered](l1, l2 []T) []T

Intersection 返回两个列表的交集

func Map

func Map[T1, T2 any](l []T1, mapper func(T1) T2) []T2

Map 列表映射

func Max

func Max[T types.Number](l []T) T

Max 返回列表中的最大值

func Member

func Member[T types.Number](l []T, v T) bool

Member 判断是否为列表成员

func Min

func Min[T types.Number](l []T) T

Min 返回列表中的最小值

func Partition

func Partition[T any](l []T, pred func(T) bool) ([]T, []T)

Partition 列表分割

func Remove

func Remove[T constraints.Ordered](l []T, v T) ([]T, bool)

Remove 移除列表成员

func Sum

func Sum[T types.Number](l []T) T

Sum 列表求和

func Union

func Union[T constraints.Ordered](l1, l2 []T) []T

Union 返回两个列表的并集

Types

This section is empty.

Jump to

Keyboard shortcuts

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