ints64

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2019 License: BSD-3-Clause Imports: 1 Imported by: 0

Documentation

Overview

Package ints64 provide a library for working with slice of 64 bit integer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Count

func Count(d []int64, class int64) (count int)

Count number of class in slice.

func Counts

func Counts(d, classes []int64) (counts []int)

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

func IndirectSort(d []int64, asc bool) (sortedIdx []int)

IndirectSort will sort the data and return the sorted index.

func InplaceMergesort

func InplaceMergesort(d []int64, idx []int, l, r int, asc bool)

InplaceMergesort in-place merge-sort without memory allocation.

func InsertionSortWithIndices

func InsertionSortWithIndices(d []int64, ids []int, l, r int, asc bool)

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

func IsExist(d []int64, v int64) bool

IsExist will return true if value `v` exist in slice of `d`, otherwise it will return false.

func Max

func Max(d []int64) (v int64, i int, ok bool)

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

func MaxCountOf(d, classes []int64) (int64, bool)

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

func MaxRange(d []int64, l, r int) (v int64, i int)

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

func Min(d []int64) (v int64, i int, ok bool)

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

func MinRange(d []int64, l, r int) (v int64, i int)

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

func SortByIndex(d *[]int64, sortedIds []int)

SortByIndex will sort the slice `d` using sorted index `sortedIds`.

func Sum

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

Sum all value in slice.

func Swap

func Swap(d []int64, x, y int)

Swap two indices value of slice.

Types

This section is empty.

Jump to

Keyboard shortcuts

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