array

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2025 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Chunk

func Chunk[T ~[]E, E any](list T, size int) []T

Chunk 集合分片

func Diff

func Diff[T ~[]E, E comparable](list1 T, list2 T) (ret1 T, ret2 T)

Diff 返回两个集合之间的差异

func DiffT

func DiffT[T ~[]C, C Constraint[E], E comparable](list1 T, list2 T) (ret1 T, ret2 T)

DiffT 返回两个集合之间的差异

func In

func In[T ~[]E, E comparable](list T, elem E) bool

In 返回指定元素是否在集合中

func InT

func InT[T ~[]C, C Constraint[E], E comparable](list T, elem E) bool

InT 返回指定元素是否在集合中

func Intersect

func Intersect[T ~[]E, E comparable](list1 T, list2 T) T

Intersect 返回两个集合的交集

func IntersectT

func IntersectT[T ~[]C, C Constraint[E], E comparable](list1 T, list2 T) T

IntersectT 返回两个集合的交集

func PinTop

func PinTop[T ~[]E, E any](list T, index int)

PinTop 置顶集合中的一个元素

func PinTopFunc

func PinTopFunc[T ~[]E, E any](list T, fn func(v E) bool)

PinTopF 置顶集合中满足条件的一个元素

func Rand

func Rand[T ~[]E, E any](list T, n int) T

Rand 返回一个指定随机挑选个数的切片 若 n == -1 or n >= len(list),则返回打乱的切片

func Union

func Union[T ~[]E, E comparable](lists ...T) T

Union 返回两个集合的并集

func UnionT

func UnionT[T ~[]C, C Constraint[E], E comparable](lists ...T) T

UnionT 返回两个集合的并集

func Unique

func Unique[T ~[]E, E comparable](list T) T

Unique 集合去重

func UniqueT

func UniqueT[T ~[]C, C Constraint[E], E comparable](list T) T

UniqueT 集合去重

func Without

func Without[T ~[]E, E comparable](list T, exclude ...E) T

Without 返回不包括所有给定值的切片

func WithoutT

func WithoutT[T ~[]C, C Constraint[E], E comparable](list T, exclude ...E) T

WithoutT 返回不包括所有给定值的切片

Types

type Constraint

type Constraint[E comparable] interface {
	Element() E
}

Jump to

Keyboard shortcuts

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