coll

package
v0.0.0-...-018d782 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

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

Distinct 去重

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
	Add(ele E)

	// Remove 移除集合中的一个元素ele
	Remove(ele E) bool

	// Size 返回集合的长度
	Size() int

	// Contains 判断集合中是否包含元素ele
	Contains(ele E) bool

	// IsEmpty 判断集合是否为空集合
	IsEmpty() bool
}

type List

type List[E comparable] []E

List 切片的别名

func OfList

func OfList[E comparable](list *[]E) *List[E]

OfList 将切片指针转化为List

func (*List[E]) Add

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

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

func (*List[E]) AddAll

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

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

func (*List[E]) AddAllAt

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

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

func (*List[E]) AddAt

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

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

func (*List[E]) Contains

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

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

func (*List[E]) ForEach

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

ForEach 切片的循环操作

func (*List[E]) Get

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

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

func (*List[E]) IndexOf

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

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

func (*List[E]) IsEmpty

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

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

func (*List[E]) LastIndexOf

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

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

func (*List[E]) Lists

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

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

func (*List[E]) Remove

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

Remove 删除切片中的元素ele

func (*List[E]) RemoveAll

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

RemoveAll 删除切片中的元素eles

func (*List[E]) RemoveAt

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

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

func (*List[E]) RemoveIf

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

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

func (*List[E]) RetainAll

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

RetainAll 保留切片中的元素eles

func (*List[E]) Size

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

Size 返回切片的大小

func (*List[E]) Stream

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

Stream 将List转化为Stream流处理

func (*List[E]) ToSet

func (my *List[E]) ToSet() *Set[E]

type Set

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

func OfSet

func OfSet[E comparable](set *map[E]struct{}) *Set[E]

func OfSet4Arr

func OfSet4Arr[E comparable](arr []E) *Set[E]

func (*Set[E]) Add

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

func (*Set[E]) Contains

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

func (*Set[E]) IsEmpty

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

func (*Set[E]) Remove

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

func (*Set[E]) Size

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

func (*Set[E]) ToList

func (my *Set[E]) ToList() *List[E]

Jump to

Keyboard shortcuts

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