math

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Abs

func Abs(n int32) uint32

Abs func

func GenerateRandomBytes

func GenerateRandomBytes(n int) ([]byte, error)

GenerateRandomBytes returns securely generated random bytes. It will return an error if the system's secure random number generator fails to function correctly, in which GenerateRandomBytes case the caller should not continue.

func GenerateRandomString

func GenerateRandomString(s int) (string, error)

GenerateRandomString returns a URL-safe, base64 encoded securely generated random string. It will return an error if the system's secure random number generator fails to function correctly, in which GenerateRandomString case the caller should not continue.

func HmacSha1

func HmacSha1(content []byte, key []byte) string

HmacSha1 func

func HmacSha256

func HmacSha256(content []byte, key []byte) string

HmacSha256 func

func HmacSha256ByString

func HmacSha256ByString(contentstr string, keystr string) string

HmacSha256ByString func

func RandBetween

func RandBetween(min, max int) int

RandBetween rand a num between min to max

func RandWeight

func RandWeight(weight []uint32) uint32

RandWeight 根据权重列表随机出一个结果,返回命中下标

func RandWeightStruct

func RandWeightStruct(weight []UtilWeightInterface) interface{}

RandWeightStruct 根据权重列表随机出一个结果,返回命中下标

func SliceOutOfOrder

func SliceOutOfOrder(in []string) []string

SliceOutOfOrder 乱序切片

func SliceOutOfOrderByInt

func SliceOutOfOrderByInt(in []uint64) []uint64

SliceOutOfOrderByInt 乱序切片

Types

type UtilWeightInterface

type UtilWeightInterface interface {
	GetWeight() uint32
}

UtilWeightInterface infterface

type ValueWeightPair

type ValueWeightPair struct {
	// contains filtered or unexported fields
}

ValueWeightPair 权值对,根据权重随机一个值出来

func NewValueWeightPair

func NewValueWeightPair() *ValueWeightPair

NewValueWeightPair new value weight pair

func (*ValueWeightPair) Add

func (v *ValueWeightPair) Add(weight uint32, value uint64)

Add add weight

func (*ValueWeightPair) Random

func (v *ValueWeightPair) Random() uint64

Random random a num

Jump to

Keyboard shortcuts

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