cherrySlice

package
v1.3.12 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2023 License: MIT Imports: 6 Imported by: 9

Documentation

Overview

Package cherrySlice code from: https://github.com/beego/beego/blob/develop/core/utils/slice.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Chunk

func Chunk(slice []interface{}, size int) (chunkSlice [][]interface{})

Chunk separates one slice to some sized slice.

func Diff

func Diff(slice1, slice2 []interface{}) (diffSlice []interface{})

Diff returns diff slice of slice1 - slice2.

func Filter

func Filter(slice []interface{}, a func(interface{}) bool) (filterSlice []interface{})

Filter generates a new slice after filter function.

func InInterface

func InInterface(v interface{}, sl []interface{}) bool

InInterface checks given interface in interface slice.

func Int32In added in v1.1.20

func Int32In(v int32, sl []int32) (int, bool)

func Int64In added in v1.1.24

func Int64In(v int64, sl []int64) (int, bool)

func Intersect

func Intersect(slice1, slice2 []interface{}) (diffSlice []interface{})

Intersect returns slice that are present in all the slice1 and slice2.

func IsEmptyWithString added in v1.3.0

func IsEmptyWithString(p []string) bool

func IsSlice added in v1.1.29

func IsSlice(value interface{}) bool

IsSlice checks whether given value is array/slice. Note that it uses reflect internally implementing this feature.

func Merge

func Merge(slice1, slice2 []interface{}) (c []interface{})

Merge merges interface slices to one slice.

func Pad

func Pad(slice []interface{}, size int, val interface{}) []interface{}

Pad prepends size number of val into slice.

func Rand

func Rand(a []interface{}) (b interface{})

Rand returns random one from slice.

func RandList

func RandList(minValue, maxValue int) []int

RandList generate an int slice from min to max.

func Range

func Range(start, end, step int64) (intSlice []int64)

Range generates a new slice from begin to end with step duration of int64 number.

func Reduce

func Reduce(slice []interface{}, a func(interface{}) interface{}) (destSlice []interface{})

Reduce generates a new slice after parsing every value by reduce function

func Shuffle

func Shuffle(slice []interface{}) []interface{}

Shuffle shuffles a slice.

func StringIn added in v1.1.20

func StringIn(v string, sl []string) (int, bool)

StringIn checks given string in string slice or not.

func StringInSlice added in v1.3.1

func StringInSlice(v string, sl []string) bool

func StringToInt added in v1.1.29

func StringToInt(strSlice []string) []int

func StringToInt32 added in v1.1.29

func StringToInt32(strSlice []string) []int32

func StringToInt64 added in v1.1.29

func StringToInt64(strSlice []string) []int64

func Sum

func Sum(intslice []int64) (sum int64)

Sum sums all values in int64 slice.

func Unique

func Unique[T comparable](slice ...T) []T

Unique cleans repeated values in slice.

func Uniques added in v1.3.4

func Uniques[T comparable](slices ...[]T) []T

Types

This section is empty.

Jump to

Keyboard shortcuts

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