arrayutil

package
v0.0.0-...-ee0865d Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2021 License: MIT, MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Contains

func Contains(length int, predicate func(i int) bool) bool

func IndexOf

func IndexOf(length int, predicate func(i int) bool) int

func IndexOfInt

func IndexOfInt(arr []int, item int) int

func RemoveAt

func RemoveAt(arr *[]interface{}, i int)

func RemoveRep

func RemoveRep(slc []string) []string

元素去重

func RemoveRepByLoop

func RemoveRepByLoop(slc []string) []string

通过两重循环过滤重复元素

func RemoveRepByMap

func RemoveRepByMap(slc []string) []string

通过map主键唯一的特性过滤重复元素

func Unique

func Unique(a []string) (ret []string)

移除重复和空的值

Types

type Array2D

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

func NewArray2D

func NewArray2D(width int, height int, defaultValue int) *Array2D

func (*Array2D) GetData

func (a2d *Array2D) GetData() []int

func (*Array2D) GetIndex

func (a2d *Array2D) GetIndex(col int, row int) int

func (*Array2D) GetValue

func (a2d *Array2D) GetValue(col int, row int) int

func (*Array2D) GetValueByIndex

func (a2d *Array2D) GetValueByIndex(index int) int

func (*Array2D) SetValue

func (a2d *Array2D) SetValue(col int, row int, value int)

type ArrayList

type ArrayList []interface{}

func (*ArrayList) Add

func (arr *ArrayList) Add(items ...interface{})

添加, 如果存在, 不处理

func (*ArrayList) AddConf

func (arr *ArrayList) AddConf(cond func(item interface{}) bool, items ...interface{})

添加, 如果存在, 不处理

func (*ArrayList) At

func (arr *ArrayList) At(index int) interface{}

func (*ArrayList) Clear

func (arr *ArrayList) Clear()

func (*ArrayList) Clone

func (arr *ArrayList) Clone() ArrayList

func (*ArrayList) Contains

func (arr *ArrayList) Contains(item interface{}) bool

func (*ArrayList) ContainsCond

func (arr *ArrayList) ContainsCond(cond func(item interface{}) bool) bool

func (*ArrayList) CountCond

func (arr *ArrayList) CountCond(cond func(item interface{}) bool) int

按照条件计数

func (*ArrayList) Every

func (arr *ArrayList) Every(cond func(item interface{}) bool) bool

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

func (*ArrayList) Filter

func (arr *ArrayList) Filter(cond func(index int, item interface{}) bool) (r ArrayList)

func (*ArrayList) First

func (arr *ArrayList) First(cond func(item interface{}) bool) (val interface{}, has bool)

func (*ArrayList) ForRange

func (arr *ArrayList) ForRange(handler func(item interface{}))

func (*ArrayList) IndexOf

func (arr *ArrayList) IndexOf(item interface{}) int

func (*ArrayList) IndexOfConf

func (arr *ArrayList) IndexOfConf(cond func(item interface{}) bool) int

func (*ArrayList) Last

func (arr *ArrayList) Last(cond func(item interface{}) bool) interface{}

func (*ArrayList) Length

func (arr *ArrayList) Length() int

func (*ArrayList) Pop

func (arr *ArrayList) Pop() interface{}

func (*ArrayList) Push

func (arr *ArrayList) Push(item interface{})

func (*ArrayList) PushList

func (arr *ArrayList) PushList(list ArrayList)

func (*ArrayList) Remove

func (arr *ArrayList) Remove(item interface{})

func (*ArrayList) RemoveAt

func (arr *ArrayList) RemoveAt(i int)

func (*ArrayList) Replace

func (arr *ArrayList) Replace(i int, item interface{})

func (*ArrayList) Reverse

func (arr *ArrayList) Reverse()

func (*ArrayList) Set

func (arr *ArrayList) Set(index int, val interface{})

func (*ArrayList) Shift

func (arr *ArrayList) Shift() interface{}

func (*ArrayList) Slice

func (arr *ArrayList) Slice() []interface{}

func (*ArrayList) Sort

func (arr *ArrayList) Sort(compare func(a, b interface{}) int)

func (*ArrayList) Union

func (arr *ArrayList) Union(a ArrayList, getKey func(a interface{}) string) ArrayList

并集

func (*ArrayList) UnionByCustomKey

func (arr *ArrayList) UnionByCustomKey(a ArrayList, getKey func(a interface{}) string) ArrayList

并集

func (*ArrayList) Unique

func (arr *ArrayList) Unique() (r ArrayList)

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

func (*ArrayList) UniqueByCustomKey

func (arr *ArrayList) UniqueByCustomKey(getKey func(item interface{}) string) (r ArrayList)

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

func (*ArrayList) Unshift

func (arr *ArrayList) Unshift(item interface{})

type ArrayListInt

type ArrayListInt []int

func (*ArrayListInt) Add

func (arr *ArrayListInt) Add(items ...int)

添加, 如果存在, 不处理

func (*ArrayListInt) At

func (arr *ArrayListInt) At(index int) int

func (*ArrayListInt) Clear

func (arr *ArrayListInt) Clear()

func (*ArrayListInt) Clone

func (arr *ArrayListInt) Clone() ArrayListInt

func (*ArrayListInt) Contains

func (arr *ArrayListInt) Contains(item int) bool

func (*ArrayListInt) ContainsCond

func (arr *ArrayListInt) ContainsCond(cond func(item int) bool) bool

func (*ArrayListInt) Every

func (arr *ArrayListInt) Every(cond func(item int) bool) bool

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

func (*ArrayListInt) Filter

func (arr *ArrayListInt) Filter(cond func(index int, elem int) bool) (r ArrayListInt)

过滤数组, 返回符合条件[conf]的新数组

func (*ArrayListInt) First

func (arr *ArrayListInt) First(cond func(item int) bool) (int, bool)

func (*ArrayListInt) ForRange

func (arr *ArrayListInt) ForRange(handler func(item int))

func (*ArrayListInt) IndexOf

func (arr *ArrayListInt) IndexOf(item int) int

func (*ArrayListInt) IndexOfConf

func (arr *ArrayListInt) IndexOfConf(cond func(item int) bool) int

func (*ArrayListInt) Last

func (arr *ArrayListInt) Last(cond func(item int) bool) int

func (*ArrayListInt) Length

func (arr *ArrayListInt) Length() int

func (*ArrayListInt) Pop

func (arr *ArrayListInt) Pop() int

func (*ArrayListInt) Push

func (arr *ArrayListInt) Push(item int)

func (*ArrayListInt) PushList

func (arr *ArrayListInt) PushList(list ArrayListInt)

func (*ArrayListInt) Remove

func (arr *ArrayListInt) Remove(item int)

func (*ArrayListInt) RemoveAt

func (arr *ArrayListInt) RemoveAt(i int)

func (*ArrayListInt) Replace

func (arr *ArrayListInt) Replace(i int, item int)

func (*ArrayListInt) Reverse

func (arr *ArrayListInt) Reverse()

func (*ArrayListInt) Shift

func (arr *ArrayListInt) Shift() int

func (*ArrayListInt) Slice

func (arr *ArrayListInt) Slice() []int

func (*ArrayListInt) Sort

func (arr *ArrayListInt) Sort(compare func(a, b int) int)

func (*ArrayListInt) Union

func (arr *ArrayListInt) Union(a ArrayListInt, getKey func(a int) string) ArrayListInt

并集

func (*ArrayListInt) Unique

func (arr *ArrayListInt) Unique(getKey func(a int) string) (r ArrayListInt)

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

func (*ArrayListInt) Unshift

func (arr *ArrayListInt) Unshift(item int)

type ByteArray

type ByteArray []byte

func (*ByteArray) IndexOf

func (arr *ByteArray) IndexOf(item byte) int

func (*ByteArray) IndexOfFunc

func (arr *ByteArray) IndexOfFunc(predicate func(item byte) bool) int

func (*ByteArray) Pop

func (arr *ByteArray) Pop() interface{}

func (*ByteArray) Push

func (arr *ByteArray) Push(item byte)

func (*ByteArray) RemoveAt

func (arr *ByteArray) RemoveAt(i int)

func (*ByteArray) Replace

func (arr *ByteArray) Replace(i int, item byte)

func (*ByteArray) Shift

func (arr *ByteArray) Shift() interface{}

func (*ByteArray) Unshift

func (arr *ByteArray) Unshift(item byte)

Jump to

Keyboard shortcuts

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