Documentation ¶
Overview ¶
Package ints64 provide a library for working with slice of 64 bit integer.
Index ¶
- func Count(d []int64, class int64) (count int)
- func Counts(d, classes []int64) (counts []int)
- func IndirectSort(d []int64, asc bool) (sortedIdx []int)
- func InplaceMergesort(d []int64, idx []int, l, r int, asc bool)
- func InsertionSortWithIndices(d []int64, ids []int, l, r int, asc bool)
- func IsExist(d []int64, v int64) bool
- func Max(d []int64) (v int64, i int, ok bool)
- func MaxCountOf(d, classes []int64) (int64, bool)
- func MaxRange(d []int64, l, r int) (v int64, i int)
- func Min(d []int64) (v int64, i int, ok bool)
- func MinRange(d []int64, l, r int) (v int64, i int)
- func SortByIndex(d *[]int64, sortedIds []int)
- func Sum(d []int64) (sum int64)
- func Swap(d []int64, x, y int)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Counts ¶
Counts number of each class in slice.
For example, if data is "[3,3,4]" and classes is "[3,4,5]", this function will return "[2,1,0]".
func IndirectSort ¶
IndirectSort will sort the data and return the sorted index.
func InplaceMergesort ¶
InplaceMergesort in-place merge-sort without memory allocation.
func InsertionSortWithIndices ¶
InsertionSortWithIndices will sort the data using insertion-sort algorithm.
Parameters: `d` is slice that will be sorted, `ids` is indices of data "d", `l` is starting index of slice to be sorted, and `r` is end index of slice to be sorted.
func IsExist ¶
IsExist will return true if value `v` exist in slice of `d`, otherwise it will return false.
func Max ¶
Max find the maximum value in slice and return its value and index.
If slice is empty, it will return false in ok.
func MaxCountOf ¶
MaxCountOf count number of occurrence of each element of classes in data and return the class with maximum count.
If `classes` is empty, it will return -1 and false. If `data` is empty, it will return -2 and false. If two or more class has the same count value, then the first max in the class will be returned.
For example, given a data [0, 1, 0, 1, 0] and classes [0, 1], the function will count 0 as 3, 1 as 2; and return (0, true).
func MaxRange ¶
MaxRange find the (last) maximum value in range of slice between index "l" and "r".
WARNING: Caller must check for out of range index of "l" or "r" before calling this function or it will be panic.
func Min ¶
Min find the minimum value in slice and return its value and index.
If slice is empty, it will return false in ok.
func MinRange ¶
MinRange find the (last) minimum value in range of slice between "l" to "r" index.
WARNING: this function does not check if slice is empty or index value of "l" or "r" out of range, it other words you must check manually before calling this function of it will become panic.
func SortByIndex ¶
SortByIndex will sort the slice `d` using sorted index `sortedIds`.
Types ¶
This section is empty.