constraints

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

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

type List

type List[V comparable] struct {
	// contains filtered or unexported fields
}

func NewList

func NewList[V comparable]() (obj *List[V])

func (*List[V]) Add

func (list *List[V]) Add(items ...V)

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

func (*List[V]) AddConf

func (list *List[V]) AddConf(cond func(index int, item V) bool, items ...V)

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

func (*List[V]) At

func (list *List[V]) At(index int) (result V)

func (*List[V]) Clear

func (list *List[V]) Clear()

func (*List[V]) Clone

func (list *List[V]) Clone() *List[V]

func (*List[V]) Contains

func (list *List[V]) Contains(item V) bool

func (*List[V]) ContainsCond

func (list *List[V]) ContainsCond(cond func(index int, item V) bool) bool

func (*List[V]) CountCond

func (list *List[V]) CountCond(cond func(index int, item V) bool) int

CountCond 按照条件计数

func (*List[V]) Dispose

func (list *List[V]) Dispose()

func (*List[V]) Every

func (list *List[V]) Every(cond func(index int, item V) bool) bool

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

func (*List[V]) Filter

func (list *List[V]) Filter(cond func(index int, item V) bool) *List[V]

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

func (*List[V]) First

func (list *List[V]) First(cond func(index int, item V) bool) (val V, has bool)

func (*List[V]) ForRange

func (list *List[V]) ForRange(handler func(index int, item V) error)

如果返回错误,迭代终止

func (*List[V]) ForRangeFromLast

func (list *List[V]) ForRangeFromLast(handler func(index int, item V) error)

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

func (*List[V]) GroupByCount

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

GroupByCount 按指定数量分组

func (*List[V]) GroupByCustomKey

func (list *List[V]) GroupByCustomKey(getKey func(item V) string) map[string]*List[V]

func (*List[V]) IndexOf

func (list *List[V]) IndexOf(item V) int

返回项的索引

func (*List[V]) IndexOfConf

func (list *List[V]) IndexOfConf(cond func(index int, item V) bool) int

返回符合条件的项的索引

func (*List[V]) Insert

func (list *List[V]) Insert(i int, item V)

func (*List[V]) Last

func (list *List[V]) Last(cond func(index int, item V) bool) (result V, has bool)

func (*List[V]) Length

func (list *List[V]) Length() int

func (*List[V]) Pop

func (list *List[V]) Pop() V

func (*List[V]) Push

func (list *List[V]) Push(item V)

func (*List[V]) PushList

func (list *List[V]) PushList(val IList[V])

func (*List[V]) Remove

func (list *List[V]) Remove(item V)

func (*List[V]) RemoveAt

func (list *List[V]) RemoveAt(i int)

func (*List[V]) Replace

func (list *List[V]) Replace(i int, item V)

func (*List[V]) Reverse

func (list *List[V]) Reverse()

func (*List[V]) Self

func (list *List[V]) Self() *List[V]

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

func (*List[V]) Set

func (list *List[V]) Set(index int, val V)

func (*List[V]) SetList

func (list *List[V]) SetList(val []V)

func (*List[V]) Shift

func (list *List[V]) Shift() V

func (*List[V]) Slice

func (list *List[V]) Slice() []V

Slice 直接返回slice值

func (*List[V]) Sort

func (list *List[V]) Sort(compare func(a, b V) int)

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

func (*List[V]) Union

func (list *List[V]) Union(a IList[V]) *List[V]

Union 并集

func (*List[V]) UnionByCustomKey

func (list *List[V]) UnionByCustomKey(a IList[V], getKey func(item V) string) *List[V]

UnionByCustomKey 并集

func (*List[V]) Unique

func (list *List[V]) Unique() *List[V]

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

func (*List[V]) UniqueByCustomKey

func (list *List[V]) UniqueByCustomKey(getKey func(item V) string) *List[V]

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

func (*List[V]) Unshift

func (list *List[V]) Unshift(item V)

Jump to

Keyboard shortcuts

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