slice

package
v0.0.0-...-806eab8 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2023 License: Apache-2.0 Imports: 6 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddAt

func AddAt[T comparable](src []T, index int, ele T) []T

func BatchConsume

func BatchConsume[T comparable](list []T, batchSize int, consumer func([]T))

BatchConsume 分批处理,每batchSize一批

func Contains

func Contains[T comparable](list []T, ele T) bool

func ContainsIgnoreCase

func ContainsIgnoreCase(slice []string, ele string) bool

func ContainsIgnoreCaseReturnEle

func ContainsIgnoreCaseReturnEle(slice []string, ele string) (bool, string)

func ConvertEle

func ConvertEle[T any, R any](ts []T, t2r func(t T) R) []R

func Distinct

func Distinct[T comparable](list []T) []T

func Page

func Page[T comparable](list []T, subSize int) [][]T

Page 根据subSize分页

func Remove

func Remove[T comparable](src []T, ele T) []T

func RemoveAt

func RemoveAt[T comparable](src []T, index int) []T

Types

type Collection

type Collection[E comparable] interface {
	Add(ele E)
	Remove(ele E) bool
	Size() int
	Contains(ele E) bool
	IsEmpty() bool
}

type List

type List[E comparable] []E

List 切片的别名

func (*List[E]) Add

func (self *List[E]) Add(ele E)

Add 在切片末尾添加一个元素ele

func (*List[E]) AddAll

func (self *List[E]) AddAll(eles []E)

AddAll 在切片末尾添加len(eles)个元素eles

func (*List[E]) AddAllAt

func (self *List[E]) AddAllAt(index int, eles []E)

AddAllAt 从切片index索引位置开始添加len(eles)个元素eles

func (*List[E]) AddAt

func (self *List[E]) AddAt(index int, ele E)

AddAt 在切片index索引位置添加一个元素ele

func (*List[E]) Contains

func (self *List[E]) Contains(ele E) bool

Contains 返回切片是否包含元素ele的布尔值

func (*List[E]) ForEach

func (self *List[E]) ForEach(action func(t E))

ForEach 切片的循环操作

func (*List[E]) Get

func (self *List[E]) Get(index int) E

Get 返回切片索引index处的元素

func (*List[E]) IndexOf

func (self *List[E]) IndexOf(ele E) int

IndexOf 返回ele对应切片最近一个元素的索引下标,没有则返回-1

func (*List[E]) IsEmpty

func (self *List[E]) IsEmpty() bool

IsEmpty 返回切片是否为空的布尔值

func (*List[E]) LastIndexOf

func (self *List[E]) LastIndexOf(ele E) int

LastIndexOf 返回ele对应切片最后一个元素的索引下标,没有则返回-1

func (*List[E]) Lists

func (self *List[E]) Lists(subSize int) [][]E

Lists 返回切片的子切片的切片(子切片大小为subSize)

func (*List[E]) Remove

func (self *List[E]) Remove(ele E) bool

Remove 删除切片中的元素ele

func (*List[E]) RemoveAll

func (self *List[E]) RemoveAll(eles []E)

RemoveAll 删除切片中的元素eles

func (*List[E]) RemoveAt

func (self *List[E]) RemoveAt(index int) bool

RemoveAt 删除切片index索引位置的元素

func (*List[E]) RemoveIf

func (self *List[E]) RemoveIf(predicate func(ele E) bool)

RemoveIf 删除表达式predicate为true的切片中的元素

func (*List[E]) RetainAll

func (self *List[E]) RetainAll(eles []E)

RetainAll 保留切片中的元素eles

func (*List[E]) Size

func (self *List[E]) Size() int

Size 返回切片的大小

func (*List[E]) Stream

func (self *List[E]) Stream() streams.Stream[E]

Stream 将List转化为Stream流处理

type Set

type Set[E comparable] map[E]struct{}

func (*Set[E]) Add

func (this *Set[E]) Add(ele E)

func (*Set[E]) Contains

func (this *Set[E]) Contains(ele E) bool

func (*Set[E]) IsEmpty

func (this *Set[E]) IsEmpty() bool

func (*Set[E]) Remove

func (this *Set[E]) Remove(ele E) bool

func (*Set[E]) Size

func (this *Set[E]) Size() int

Jump to

Keyboard shortcuts

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