slice

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2022 License: BSD-2-Clause Imports: 7 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// ValueIsNotContained means the value is not contained in the slice.
	ValueIsNotContained = -1
)

Variables

This section is empty.

Functions

func Contain

func Contain(slice, value interface{}) (index int)

Contain returns the index of the first instance of value in slice, or -1 if value is not present in slice. It panics if slice is invalid.

func ContainBool

func ContainBool(slice []bool, value bool) (index int)

ContainBool returns the index of the first instance of bool value in bool slice, or -1 if value is not present in bool slice.

func ContainFloat

func ContainFloat(slice []float64, value float64, places ...int) (index int)

ContainFloat returns the index of the first instance of float64 value in float64 slice, or -1 if value is not present in float64 slice. It will be judged equal if | v1 - v2 | <= 10 ^ -places, default places is 9.

func ContainFloat32

func ContainFloat32(slice []float32, value float32, places ...int) (index int)

ContainFloat32 returns the index of the first instance of float32 value in float32 slice, or -1 if value is not present in float32 slice. It will be judged equal if | v1 - v2 | <= 10 ^ -places, default places is 9.

func ContainFloat64

func ContainFloat64(slice []float64, value float64, places ...int) (index int)

ContainFloat64 returns the index of the first instance of float64 value in float64 slice, or -1 if value is not present in float64 slice. It will be judged equal if | v1 - v2 | <= 10 ^ -places, default places is 9.

func ContainInt

func ContainInt(slice []int, value int) (index int)

ContainInt returns the index of the first instance of int value in int slice, or -1 if value is not present in int slice.

func ContainInt32

func ContainInt32(slice []int32, value int32) (index int)

ContainInt32 returns the index of the first instance of int32 value in int32 slice, or -1 if value is not present in int32 slice.

func ContainInt64

func ContainInt64(slice []int64, value int64) (index int)

ContainInt64 returns the index of the first instance of int64 value in int64 slice, or -1 if value is not present in int64 slice.

func ContainString

func ContainString(slice []string, value string) (index int)

ContainString returns the index of the first instance of string value in string slice, or -1 if value is not present in string slice.

func Count

func Count(slice interface{}) map[interface{}]int

Count returns value count map by slice.

func CountBool

func CountBool(slice []bool) map[bool]int

CountBool returns bool value count map by bool slice.

func CountFloat

func CountFloat(slice []float64) map[float64]int

CountFloat returns float64 value count map by float64 slice.

func CountFloat32

func CountFloat32(slice []float32) map[float32]int

CountFloat32 returns float32 value count map by float32 slice.

func CountFloat64

func CountFloat64(slice []float64) map[float64]int

CountFloat64 returns float64 value count map by float64 slice.

func CountInt

func CountInt(slice []int) map[int]int

CountInt returns int value count map by int slice.

func CountInt32

func CountInt32(slice []int32) map[int32]int

CountInt32 returns int32 value count map by int32 slice.

func CountInt64

func CountInt64(slice []int64) map[int64]int

CountInt64 returns int64 value count map by int64 slice.

func CountString

func CountString(slice []string) map[string]int

CountString returns string value count map by string slice.

func Delete

func Delete(slice, value interface{}, n int) ([]interface{}, int)

Delete returns the slice that deletes n specified value and the number of actual deletions. If n < 0, it will delete all specified value.

func DeleteBool

func DeleteBool(slice []bool, value bool, n int) ([]bool, int)

DeleteBool returns the slice that deletes n specified bool value and the number of actual deletions. If n < 0, it will delete all specified bool value.

func DeleteFloat

func DeleteFloat(slice []float64, value float64, n int, places ...int) ([]float64, int)

DeleteFloat returns the slice that deletes n specified float64 value and the number of actual deletions. If n < 0, it will delete all specified float64 value. It will be judged equal if | v1 - v2 | <= 10 ^ -places, default places is 9.

func DeleteFloat32

func DeleteFloat32(slice []float32, value float32, n int, places ...int) ([]float32, int)

DeleteFloat32 returns the slice that deletes n specified float32 value and the number of actual deletions. If n < 0, it will delete all specified float32 value. It will be judged equal if | v1 - v2 | <= 10 ^ -places, default places is 9.

func DeleteFloat64

func DeleteFloat64(slice []float64, value float64, n int, places ...int) ([]float64, int)

DeleteFloat64 returns the slice that deletes n specified float64 value and the number of actual deletions. If n < 0, it will delete all specified float64 value. It will be judged equal if | v1 - v2 | <= 10 ^ -places, default places is 9.

func DeleteInt

func DeleteInt(slice []int, value, n int) ([]int, int)

DeleteInt returns the slice that deletes n specified int value and the number of actual deletions. If n < 0, it will delete all specified int value.

func DeleteInt32

func DeleteInt32(slice []int32, value int32, n int) ([]int32, int)

DeleteInt32 returns the slice that deletes n specified int32 value and the number of actual deletions. If n < 0, it will delete all specified int32 value.

func DeleteInt64

func DeleteInt64(slice []int64, value int64, n int) ([]int64, int)

DeleteInt64 returns the slice that deletes n specified int64 value and the number of actual deletions. If n < 0, it will delete all specified int64 value.

func DeleteString

func DeleteString(slice []string, value string, n int) ([]string, int)

DeleteString returns the slice that deletes n specified string value and the number of actual deletions. If n < 0, it will delete all specified string value.

func Equal

func Equal(arr1, arr2 interface{}) bool

Equal reports whether arr1 equals arr2. It panics if arr1 or arr2 is invalid.

func EqualBools

func EqualBools(arr1, arr2 []bool) bool

EqualBools reports whether bool arr1 equals bool arr2.

func EqualFloat32s

func EqualFloat32s(arr1, arr2 []float32, places ...int) bool

EqualFloat32s reports whether float32 arr1 equals float32 arr2. It will be judged equal if | v1 - v2 | <= 10 ^ -places, default places is 9.

func EqualFloat64s

func EqualFloat64s(arr1, arr2 []float64, places ...int) bool

EqualFloat64s reports whether float64 arr1 equals float64 arr2. It will be judged equal if | v1 - v2 | <= 10 ^ -places, default places is 9.

func EqualFloats

func EqualFloats(arr1, arr2 []float64, places ...int) bool

EqualFloats reports whether float64 arr1 equals float64 arr2. It will be judged equal if | v1 - v2 | <= 10 ^ -places, default places is 9.

func EqualInt32s

func EqualInt32s(arr1, arr2 []int32) bool

EqualInt32s reports whether int32 arr1 equals int32 arr2.

func EqualInt64s

func EqualInt64s(arr1, arr2 []int64) bool

EqualInt64s reports whether int64 arr1 equals int64 arr2.

func EqualInts

func EqualInts(arr1, arr2 []int) bool

EqualInts reports whether int arr1 equals int arr2.

func EqualStrings

func EqualStrings(arr1, arr2 []string) bool

EqualStrings reports whether string arr1 equals string arr2.

func Extract

func Extract(slice interface{}, num int) []interface{}

Extract returns randomly extracted num elements from slice. It panics if slice or num is invalid.

func ExtractBools

func ExtractBools(slice []bool, num int) []bool

ExtractBools returns randomly extracted num elements from bool slice. It panics if num is invalid.

func ExtractFloat32s

func ExtractFloat32s(slice []float32, num int) []float32

ExtractFloat32s returns randomly extracted num elements from float32 slice. It panics if num is invalid.

func ExtractFloat64s

func ExtractFloat64s(slice []float64, num int) []float64

ExtractFloat64s returns randomly extracted num elements from float64 slice. It panics if num is invalid.

func ExtractFloats

func ExtractFloats(slice []float64, num int) []float64

ExtractFloats returns randomly extracted num elements from float64 slice. It panics if num is invalid.

func ExtractInt32s

func ExtractInt32s(slice []int32, num int) []int32

ExtractInt32s returns randomly extracted num elements from int64 slice. It panics if num is invalid.

func ExtractInt64s

func ExtractInt64s(slice []int64, num int) []int64

ExtractInt64s returns randomly extracted num elements from int64 slice. It panics if num is invalid.

func ExtractInts

func ExtractInts(slice []int, num int) []int

ExtractInts returns randomly extracted num elements from int slice. It panics if num is invalid.

func ExtractStrings

func ExtractStrings(slice []string, num int) []string

ExtractStrings returns randomly extracted num elements from string slice. It panics if num is invalid.

func Fill

func Fill(value interface{}, num int) []interface{}

Fill returns slice filled with value, where num is the number of value should be filled. It panics if num is invalid.

func FillBool

func FillBool(value bool, num int) []bool

FillBool returns bool slice filled with bool value, where num is the number of value should be filled. It panics if num is invalid.

func FillFloat

func FillFloat(value float64, num int) []float64

FillFloat returns float64 slice filled with float64 value, where num is the number of value should be filled. It panics if num is invalid.

func FillFloat32

func FillFloat32(value float32, num int) []float32

FillFloat32 returns float32 slice filled with float32 value, where num is the number of value should be filled. It panics if num is invalid.

func FillFloat64

func FillFloat64(value float64, num int) []float64

FillFloat64 returns float64 slice filled with float64 value, where num is the number of value should be filled. It panics if num is invalid.

func FillInt

func FillInt(value, num int) []int

FillInt returns int slice filled with int value, where num is the number of value should be filled. It panics if num is invalid.

func FillInt32

func FillInt32(value int32, num int) []int32

FillInt32 returns int32 slice filled with int32 value, where num is the number of value should be filled. It panics if num is invalid.

func FillInt64

func FillInt64(value int64, num int) []int64

FillInt64 returns int64 slice filled with int64 value, where num is the number of value should be filled. It panics if num is invalid.

func FillString

func FillString(value string, num int) []string

FillString returns string slice filled with string value, where num is the number of value should be filled. It panics if num is invalid.

func Float64sToInterfaces

func Float64sToInterfaces(slice []float64) []interface{}

Float64sToInterfaces returns converted interface slice by float64 slice.

func Float64sToStrings

func Float64sToStrings(slice []float64) []string

Float64sToStrings returns converted string slice by float64 slice.

func FloatsToInterfaces

func FloatsToInterfaces(slice []float64) []interface{}

FloatsToInterfaces returns converted interface slice by float64 slice.

func FloatsToStrings

func FloatsToStrings(slice []float64) []string

FloatsToStrings returns converted string slice by float64 slice.

func Int64sToInterfaces

func Int64sToInterfaces(slice []int64) []interface{}

Int64sToInterfaces returns converted interface slice by int64 slice.

func Int64sToStrings

func Int64sToStrings(slice []int64) []string

Int64sToStrings returns converted string slice by int64 slice.

func InterfacesToFloat64s

func InterfacesToFloat64s(slice []interface{}) []float64

InterfacesToFloat64s returns converted float64 slice by interface slice.

func InterfacesToFloats

func InterfacesToFloats(slice []interface{}) []float64

InterfacesToFloats returns converted float64 slice by interface slice.

func InterfacesToInt64s

func InterfacesToInt64s(slice []interface{}) []int64

InterfacesToInt64s returns converted int64 slice by interface slice.

func InterfacesToInts

func InterfacesToInts(slice []interface{}) []int

InterfacesToInts returns converted int slice by interface slice.

func InterfacesToStrings

func InterfacesToStrings(slice []interface{}) []string

InterfacesToStrings returns converted string slice by interface slice.

func IntsToInterfaces

func IntsToInterfaces(slice []int) []interface{}

IntsToInterfaces returns converted interface slice by int slice.

func IntsToStrings

func IntsToStrings(slice []int) []string

IntsToStrings returns converted string slice by int slice.

func Join

func Join(slice interface{}, sep ...string) (result string)

Join returns string result of slice connected with string sep, default sep is ",". It panics if slice is invalid.

func JoinBools

func JoinBools(slice []bool, sep ...string) (result string)

JoinBools returns string result of bool slice connected with string sep, default sep is ",".

func JoinFloat32s

func JoinFloat32s(slice []float32, sep ...string) (result string)

JoinFloat32s returns string result of float32 slice connected with string sep, default sep is ",".

func JoinFloat64s

func JoinFloat64s(slice []float64, sep ...string) (result string)

JoinFloat64s returns string result of float64 slice connected with string sep, default sep is ",".

func JoinFloats

func JoinFloats(slice []float64, sep ...string) (result string)

JoinFloats returns string result of float64 slice connected with string sep, default sep is ",".

func JoinInt32s

func JoinInt32s(slice []int32, sep ...string) (result string)

JoinInt32s returns string result of int32 slice connected with string sep, default sep is ",".

func JoinInt64s

func JoinInt64s(slice []int64, sep ...string) (result string)

JoinInt64s returns string result of int64 slice connected with string sep, default sep is ",".

func JoinInts

func JoinInts(slice []int, sep ...string) (result string)

JoinInts returns string result of int slice connected with string sep, default sep is ",".

func JoinStrings

func JoinStrings(slice []string, sep ...string) (result string)

JoinStrings returns string result of string slice connected with string sep, default sep is ",".

func Reverse

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

Reverse returns the reverse order for slice. It panics if slice is invalid.

func ReverseBools

func ReverseBools(slice []bool) []bool

ReverseBools returns the reverse order for bool slice.

func ReverseFloat32s

func ReverseFloat32s(slice []float32) []float32

ReverseFloat32s returns the reverse order for float64 slice.

func ReverseFloat64s

func ReverseFloat64s(slice []float64) []float64

ReverseFloat64s returns the reverse order for float64 slice.

func ReverseFloats

func ReverseFloats(slice []float64) []float64

ReverseFloats returns the reverse order for float64 slice.

func ReverseInt32s

func ReverseInt32s(slice []int32) []int32

ReverseInt32s returns the reverse order for int32 slice.

func ReverseInt64s

func ReverseInt64s(slice []int64) []int64

ReverseInt64s returns the reverse order for int64 slice.

func ReverseInts

func ReverseInts(slice []int) []int

ReverseInts returns the reverse order for int slice.

func ReverseStrings

func ReverseStrings(slice []string) []string

ReverseStrings returns the reverse order for string slice.

func Shuffle

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

Shuffle returns shuffled slice, it is equivalent to Extract(slice, len(slice)).

func ShuffleBools

func ShuffleBools(slice []bool) []bool

ShuffleBools returns shuffled bool slice, it is equivalent to ExtractBools(slice, len(slice)).

func ShuffleFloat32s

func ShuffleFloat32s(slice []float32) []float32

ShuffleFloat32s returns shuffled float32 slice, it is equivalent to ExtractFloat32s(slice, len(slice)).

func ShuffleFloat64s

func ShuffleFloat64s(slice []float64) []float64

ShuffleFloat64s returns shuffled float64 slice, it is equivalent to ExtractFloat64s(slice, len(slice)).

func ShuffleFloats

func ShuffleFloats(slice []float64) []float64

ShuffleFloats returns shuffled float64 slice, it is equivalent to ExtractFloats(slice, len(slice)).

func ShuffleInt32s

func ShuffleInt32s(slice []int32) []int32

ShuffleInt32s returns shuffled int32 slice, it is equivalent to ExtractInt32s(slice, len(slice)).

func ShuffleInt64s

func ShuffleInt64s(slice []int64) []int64

ShuffleInt64s returns shuffled int64 slice, it is equivalent to ExtractInt64s(slice, len(slice)).

func ShuffleInts

func ShuffleInts(slice []int) []int

ShuffleInts returns shuffled int slice, it is equivalent to ExtractInts(slice, len(slice)).

func ShuffleStrings

func ShuffleStrings(slice []string) []string

ShuffleStrings returns shuffled string slice, it is equivalent to ExtractStrings(slice, len(slice)).

func SplitBools

func SplitBools(str string, sep ...string) []bool

SplitBools slices string str into substrings separated by string sep and returns bool slice of the converted substrings between those separators, default sep is ",".

func SplitFloat32s

func SplitFloat32s(str string, sep ...string) []float32

SplitFloat32s slices string str into substrings separated by string sep and returns float32 slice of the converted substrings between those separators, default sep is ",".

func SplitFloat64s

func SplitFloat64s(str string, sep ...string) []float64

SplitFloat64s slices string str into substrings separated by string sep and returns float64 slice of the converted substrings between those separators, default sep is ",".

func SplitFloats

func SplitFloats(str string, sep ...string) []float64

SplitFloats slices string str into substrings separated by string sep and returns float64 slice of the converted substrings between those separators, default sep is ",".

func SplitInt32s

func SplitInt32s(str string, sep ...string) []int32

SplitInt32s slices string str into substrings separated by string sep and returns int32 slice of the converted substrings between those separators, default sep is ",".

func SplitInt64s

func SplitInt64s(str string, sep ...string) []int64

SplitInt64s slices string str into substrings separated by string sep and returns int64 slice of the converted substrings between those separators, default sep is ",".

func SplitInts

func SplitInts(str string, sep ...string) []int

SplitInts slices string str into substrings separated by string sep and returns int slice of the converted substrings between those separators, default sep is ",".

func SplitStrings

func SplitStrings(str string, sep ...string) []string

SplitStrings slices string str into substrings separated by string sep and returns string slice of the converted substrings between those separators, default sep is ",".

func StringsToFloat64s

func StringsToFloat64s(slice []string) []float64

StringsToFloat64s returns converted float64 slice by string slice.

func StringsToFloats

func StringsToFloats(slice []string) []float64

StringsToFloats returns converted float64 slice by string slice.

func StringsToInt64s

func StringsToInt64s(slice []string) []int64

StringsToInt64s returns converted int64 slice by string slice.

func StringsToInterfaces

func StringsToInterfaces(slice []string) []interface{}

StringsToInterfaces returns converted interface slice by string slice.

func StringsToInts

func StringsToInts(slice []string) []int

StringsToInts returns converted int slice by string slice.

func Take

func Take(slice interface{}) interface{}

Take returns the randomly taken element from slice, it is equivalent to Extract(slice, 1)[0].

func TakeBool

func TakeBool(slice []bool) bool

TakeBool returns the randomly taken bool element from bool slice, it is equivalent to ExtractBools(slice, 1)[0].

func TakeFloat

func TakeFloat(slice []float64) float64

TakeFloat returns the randomly taken float64 element from float64 slice, it is equivalent to ExtractFloats(slice, 1)[0].

func TakeFloat32

func TakeFloat32(slice []float32) float32

TakeFloat32 returns the randomly taken float32 element from float32 slice, it is equivalent to ExtractFloat32s(slice, 1)[0].

func TakeFloat64

func TakeFloat64(slice []float64) float64

TakeFloat64 returns the randomly taken float64 element from float64 slice, it is equivalent to ExtractFloat64s(slice, 1)[0].

func TakeInt

func TakeInt(slice []int) int

TakeInt returns the randomly taken int element from int slice, it is equivalent to ExtractInts(slice, 1)[0].

func TakeInt32

func TakeInt32(slice []int32) int32

TakeInt32 returns the randomly taken int32 element from int32 slice, it is equivalent to ExtractInt32s(slice, 1)[0].

func TakeInt64

func TakeInt64(slice []int64) int64

TakeInt64 returns the randomly taken int64 element from int64 slice, it is equivalent to ExtractInt64s(slice, 1)[0].

func TakeString

func TakeString(slice []string) string

TakeString returns the randomly taken string element from string slice, it is equivalent to ExtractStrings(slice, 1)[0].

func Unique

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

Unique returns the unique slice. It panics if slice is invalid.

func UniqueBools

func UniqueBools(slice []bool) []bool

UniqueBools returns the unique bool slice.

func UniqueFloat32s

func UniqueFloat32s(slice []float32) []float32

UniqueFloat32s returns the unique float32 slice.

func UniqueFloat64s

func UniqueFloat64s(slice []float64) []float64

UniqueFloat64s returns the unique float64 slice.

func UniqueFloats

func UniqueFloats(slice []float64) []float64

UniqueFloats returns the unique float64 slice.

func UniqueInt32s

func UniqueInt32s(slice []int32) []int32

UniqueInt32s returns the unique int32 slice.

func UniqueInt64s

func UniqueInt64s(slice []int64) []int64

UniqueInt64s returns the unique int64 slice.

func UniqueInts

func UniqueInts(slice []int) []int

UniqueInts returns the unique int slice.

func UniqueStrings

func UniqueStrings(slice []string) []string

UniqueStrings returns the unique string slice.

Types

This section is empty.

Jump to

Keyboard shortcuts

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