Documentation
¶
Index ¶
- func Contains(arr []interface{}, value interface{}) bool
- func ConvertSizeToString(size int) string
- func ConvertToFloat(val interface{}) (*float64, bool)
- func Difference(a, b []interface{}) []interface{}
- func Filter(arr []interface{}, test Predicate) ([]interface{}, error)
- func FunctionNameWrapper(funcName, colName string) string
- func GenerateRandomSeries(n uint64, range_ uint64, seed int64, withReplacement bool) []int
- func GetFunctionName(i interface{}) string
- func GetRealSizeOf(v interface{}) int
- func IsTimeSet(t time.Time) bool
- func LinearSearch(element interface{}, arr []interface{}) int
- func MaxIntSlice(nums []int) int
- func Range(low, high, step int) []int
- func RepeatIntoSlice(s interface{}, n int) []interface{}
- func ReverseArray(arr []interface{}) []interface{}
- func ToIntArray(arr []interface{}) []int
- func ToInterfaceFromInt(arr []int) []interface{}
- func ToInterfaceFromString(arr []string) []interface{}
- func ValueCounts(arr []interface{}) map[interface{}]int
- type Predicate
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Contains ¶
func Contains(arr []interface{}, value interface{}) bool
Contains checks if given value contains in the array
func ConvertSizeToString ¶
ConvertSizeToString will convert a number of bytes into a KB, MG, and GB string format respectively given the number of bytes.
func ConvertToFloat ¶
ConvertToFloat will convert the given empty interface value to float64. Will consider int types also. If there's an error, will return a boolean confirming the result.
func Difference ¶
func Difference(a, b []interface{}) []interface{}
Difference returns the set difference of two slices with any given values.
Only use acceptable key types for a Go map
func Filter ¶
Filter method creates an returns a new slice with all elements that pass the test implemented by the provided function.
If an error is encountered, a nil value will be returned as a slice along with the error
func FunctionNameWrapper ¶
FunctionNameWrapper returns a wrapper name with a given function name and a column name
func GenerateRandomSeries ¶
GenerateRandomSeries will generate n number of random integer values where n is in between [0, range_] using the seed value provided.
If withReplacement is set to true, the sample will contain duplicate values. And if withReplacement is set to false and if the range_ is lower than n, then the returned sample will contain number of elements equal to the range_.
func GetFunctionName ¶
func GetFunctionName(i interface{}) string
GetFunctionName will return the function name of the provided function
func GetRealSizeOf ¶
func GetRealSizeOf(v interface{}) int
GetRealSizeOf returns the number of bytes occupied by a given interface
func LinearSearch ¶
func LinearSearch(element interface{}, arr []interface{}) int
LinearSearch would search for the element in the given array and if the element is found it will return the index of the first occurrence in which it is found. If the element is not present it will return -1.
Use ToInterfaceFrom functions to quickly convert slices into interface slices to be used by the function.
Panics, if non-comparable elements are found
func MaxIntSlice ¶
MaxIntSlice returns the maximum element of a given int array
func Range ¶
Range is a helper function which generates a sequence of numbers starting from the given start integer to the stop integer by the increment of the step integer.
Panics if the step value is incorrectly specified.
func RepeatIntoSlice ¶
func RepeatIntoSlice(s interface{}, n int) []interface{}
RepeatIntoSlice takes in any empty interface element and a number of times it needs to be repeated. It will return a slice of nil interfaces instead of a compact string, as the Repeat method in strings package.
func ReverseArray ¶
func ReverseArray(arr []interface{}) []interface{}
ReverseArray reverses the given slice
func ToIntArray ¶
func ToIntArray(arr []interface{}) []int
ToIntArray converts an array of empty interfaces to an int array
func ToInterfaceFromInt ¶
func ToInterfaceFromInt(arr []int) []interface{}
ToInterfaceFromInt converts an array of int array to an empty interface array
func ToInterfaceFromString ¶
func ToInterfaceFromString(arr []string) []interface{}
ToInterfaceFromString converts an array of string array to an empty interface array
func ValueCounts ¶
func ValueCounts(arr []interface{}) map[interface{}]int
ValueCounts will find the duplicate elements from a given array of empty interfaces and will return a map containing a value count for each unique elements