2019-01-21 02:17:20 +03:00
|
|
|
package xlib
|
2019-01-14 19:53:25 +03:00
|
|
|
|
2020-05-18 23:25:15 +03:00
|
|
|
import (
|
|
|
|
"hash/fnv"
|
|
|
|
"sort"
|
|
|
|
)
|
2020-02-14 20:37:35 +03:00
|
|
|
|
2019-01-14 19:53:25 +03:00
|
|
|
//Epsilon - precission
|
|
|
|
const Epsilon float64 = 0.01
|
2019-01-21 02:17:20 +03:00
|
|
|
|
2020-02-14 20:37:35 +03:00
|
|
|
// Max - return max of two int
|
|
|
|
func Max(x, y int) int {
|
|
|
|
if x > y {
|
|
|
|
return x
|
|
|
|
}
|
|
|
|
return y
|
|
|
|
}
|
|
|
|
|
|
|
|
// SortBytes - return sorted slice of bytes
|
|
|
|
func SortBytes(b []byte) []byte {
|
|
|
|
sort.Slice(b, func(i, j int) bool { return b[i] < b[j] })
|
|
|
|
return b
|
|
|
|
}
|
2020-05-18 23:25:15 +03:00
|
|
|
|
|
|
|
// StrHash - make hash from string
|
|
|
|
func StrHash(s string) uint32 {
|
|
|
|
h := fnv.New32a()
|
|
|
|
h.Write([]byte(s))
|
|
|
|
return h.Sum32()
|
|
|
|
}
|