listx

package
v0.0.0-...-4675295 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2024 License: Apache-2.0 Imports: 3 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IList

type IList interface {
	Add(items ...interface{})
	AddConf(cond func(index int, item interface{}) bool, items ...interface{})
	Set(index int, val interface{})
	SetList(val []interface{})
	At(index int) interface{}
	Clear()
	Dispose()
	Clone() *List
	Contains(item interface{}) bool
	ContainsCond(cond func(index int, item interface{}) bool) bool
	CountCond(cond func(index int, item interface{}) bool) int
	Every(cond func(index int, item interface{}) bool) bool
	First(cond func(index int, item interface{}) bool) (val interface{}, has bool)
	Filter(cond func(index int, item interface{}) bool) *List
	ForRange(handler func(index int, item interface{}) error)
	IndexOfConf(cond func(index int, item interface{}) bool) int
	IndexOf(item interface{}) int
	Last(cond func(index int, item interface{}) bool) (val interface{}, has bool)
	Length() int
	Pop() interface{}
	Push(item interface{})
	PushList(val IList)
	Remove(item interface{})
	RemoveAt(i int)
	Replace(i int, item interface{})
	Reverse()
	Shift() interface{}
	Slice() []interface{}
	Self() *List
	Sort(compare func(a, b interface{}) int)
	Unshift(item interface{})
	Unique() *List
	UniqueByCustomKey(getKey func(item interface{}) string) *List
	Union(a IList) *List
	UnionByCustomKey(a IList, getKey func(a interface{}) string) *List

	GroupByCount(count int) (r []*List)
	GroupByCustomKey(getKey func(item interface{}) string) map[string]*List
}

type List

type List struct {
	// contains filtered or unexported fields
}

func NewList

func NewList() (obj *List)

func (*List) Add

func (list *List) Add(items ...interface{})

Add 添加元素, 如果已存在, 不添加

func (*List) AddConf

func (list *List) AddConf(cond func(index int, item interface{}) bool, items ...interface{})

AddConf 添加元素, 如果已存在相同条件[conf]的项, 不添加

func (*List) At

func (list *List) At(index int) (result interface{})

func (*List) Clear

func (list *List) Clear()

func (*List) Clone

func (list *List) Clone() *List

func (*List) Contains

func (list *List) Contains(item interface{}) bool

func (*List) ContainsCond

func (list *List) ContainsCond(cond func(index int, item interface{}) bool) bool

func (*List) CountCond

func (list *List) CountCond(cond func(index int, item interface{}) bool) int

CountCond 按照条件计数

func (*List) Dispose

func (list *List) Dispose()

func (*List) Every

func (list *List) Every(cond func(index int, item interface{}) bool) bool

Every 每一个项都符合条件就返回true

func (*List) Filter

func (list *List) Filter(cond func(index int, item interface{}) bool) *List

返回符合条件的项形成的新列表

func (*List) First

func (list *List) First(cond func(index int, item interface{}) bool) (val interface{}, has bool)

func (*List) ForRange

func (list *List) ForRange(handler func(index int, item interface{}) error)

如果返回错误,迭代终止

func (*List) ForRangeFromLast

func (list *List) ForRangeFromLast(handler func(index int, item interface{}) error)

从最后往前开始遍历 如果返回错误,迭代终止

func (*List) GroupByCount

func (list *List) GroupByCount(count int) (r []*List)

GroupByCount 按指定数量分组

func (*List) GroupByCustomKey

func (list *List) GroupByCustomKey(getKey func(item interface{}) string) map[string]*List

func (*List) IndexOf

func (list *List) IndexOf(item interface{}) int

返回项的索引

func (*List) IndexOfConf

func (list *List) IndexOfConf(cond func(index int, item interface{}) bool) int

返回符合条件的项的索引

func (*List) Insert

func (list *List) Insert(i int, item interface{})

func (*List) Last

func (list *List) Last(cond func(index int, item interface{}) bool) (result interface{}, has bool)

func (*List) Length

func (list *List) Length() int

func (*List) Pop

func (list *List) Pop() interface{}

func (*List) Push

func (list *List) Push(item interface{})

func (*List) PushList

func (list *List) PushList(val IList)

func (*List) Remove

func (list *List) Remove(item interface{})

func (*List) RemoveAt

func (list *List) RemoveAt(i int)

func (*List) Replace

func (list *List) Replace(i int, item interface{})

func (*List) Reverse

func (list *List) Reverse()

func (*List) Self

func (list *List) Self() *List

Self 返回自身的列表 用于List作为组合时的快捷方式

func (*List) Set

func (list *List) Set(index int, val interface{})

func (*List) SetList

func (list *List) SetList(val []interface{})

func (*List) Shift

func (list *List) Shift() interface{}

func (*List) Slice

func (list *List) Slice() []interface{}

Slice 直接返回slice值

func (*List) Sort

func (list *List) Sort(compare func(a, b interface{}) int)

compare返回值:>0 a排b前面

func (*List) Union

func (list *List) Union(a IList) *List

Union 并集

func (*List) UnionByCustomKey

func (list *List) UnionByCustomKey(a IList, getKey func(item interface{}) string) *List

UnionByCustomKey 并集

func (*List) Unique

func (list *List) Unique() *List

Unique 去重操作, 返回去重后的数组

func (*List) UniqueByCustomKey

func (list *List) UniqueByCustomKey(getKey func(item interface{}) string) *List

UniqueByCustomKey 去重操作, 返回去重后的数组 自定义键值

func (*List) Unshift

func (list *List) Unshift(item interface{})

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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