arrays

package
v0.0.0-...-a626ee0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SortFunc = SortFn{}

Functions

func Column

func Column(lst, out interface{}, field ...string)

Column array<M> to map[T]M

数组类型转换为 map[T]M,

其中field为需要提取的key,M为map则为keyName,M为struct则为fieldName

The array type is extracted as map type

func Contains

func Contains(lst, v interface{}, fns ...func(a, b interface{}) bool) bool

Contains Does the slice contain elements

You can pass in the comparison function, and return true to prove that they are equal

func Diff

func Diff(diff, a, b interface{})

存在A中,不存在B中,返回diff

func Each

func Each(in interface{}, fn func(v interface{}, i int))

Each 遍历, 不做返回操作

func Filter

func Filter(in, out interface{}, fn func(v interface{}, i int) bool)

Filter 过滤函数 处理函数返回true, 则保留, 不改变原数组

func IndexOf

func IndexOf(lst, v interface{}, fns ...func(a, b interface{}) bool) int

IndexOf gets the position of the element in the slice.

You can pass in the comparison function, and return true to prove that they are equal

func Joins

func Joins(lst interface{}, spec string) (s string)

Joins 合并数组为字符串,支持全类型, 使用 fmt %+v拼接

func Map

func Map(in, out interface{}, fn func(v interface{}, i int) interface{})

Map 遍历 input slice type, output slice type

通过fn函数定义修改后的返回信息

func MapSelf

func MapSelf(in interface{}, fn func(v interface{}, i int) interface{})

Map 遍历 input slice type, change input

通过fn函数定义修改后的返回信息

func Sort

func Sort(in, out interface{}, fns ...func(a, b interface{}) int8)

Sort is order by slice.

when out is nil, sort by input, input must be slice ptr.

when out is no-nil, sort by input , output out, out must be slice ptr.

func SortInt32

func SortInt32(in []int32)

func ToMap

func ToMap(in, out interface{}, fn func(item interface{}, i int) (k, v interface{}))

ToMap 将切片转换为map类型

Convert slice to map type

Types

type SortFn

type SortFn struct{}

func (SortFn) Int

func (SortFn) Int(a, b interface{}) int8

func (SortFn) Int16

func (SortFn) Int16(a, b interface{}) int8

func (SortFn) Int32

func (SortFn) Int32(a, b interface{}) int8

func (SortFn) Int64

func (SortFn) Int64(a, b interface{}) int8

func (SortFn) Int8

func (SortFn) Int8(a, b interface{}) int8

func (SortFn) String

func (SortFn) String(a, b interface{}) int8

func (SortFn) Uint

func (SortFn) Uint(a, b interface{}) int8

func (SortFn) Uint16

func (SortFn) Uint16(a, b interface{}) int8

func (SortFn) Uint32

func (SortFn) Uint32(a, b interface{}) int8

func (SortFn) Uint64

func (SortFn) Uint64(a, b interface{}) int8

func (SortFn) Uint8

func (SortFn) Uint8(a, b interface{}) int8

Jump to

Keyboard shortcuts

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