Documentation ¶
Index ¶
- func Defaultify[T comparable](v T, defaultValue T) T
- func Filter[E any](s []E, f keepFunc[E]) []E
- func FilterIsEven[T constraints.Integer](v T) bool
- func FilterIsOdd[T constraints.Integer](v T) bool
- func ForEach[E any](s []E, f forEachFunc[E]) error
- func GetMD5ShortHash(text string) string
- func Map[E any](s []E, f mapFunc1[E]) []E
- func Map2[T1, T2 any](s []T1, f mapFunc2[T1, T2]) []T2
- func OneOf[T comparable](value T, coll ...T) bool
- func PrettifyBytes(b int64) string
- func PrettifyTime(micro int64) string
- func Reduce[E any](s []E, init E, f reduceFunc[E]) E
- func Sort[E constraints.Ordered](s []E) []E
- type Balancer
- type Int64Range
- type Normalizer
- type Number
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Defaultify ¶
func Defaultify[T comparable](v T, defaultValue T) T
Defaultify returns defaultValue if v is equal to its default value.
func FilterIsEven ¶
func FilterIsEven[T constraints.Integer](v T) bool
func FilterIsOdd ¶
func FilterIsOdd[T constraints.Integer](v T) bool
func GetMD5ShortHash ¶
func OneOf ¶
func OneOf[T comparable](value T, coll ...T) bool
func PrettifyBytes ¶
func PrettifyTime ¶
func Sort ¶
func Sort[E constraints.Ordered](s []E) []E
Types ¶
type Balancer ¶
type Balancer struct {
// contains filtered or unexported fields
}
func NewBalancer ¶
func NewBalancer(items ...interface{}) *Balancer
func NewStringBalancer ¶
func (*Balancer) MustPickString ¶
type Int64Range ¶
type Int64Range struct {
Min, Max int64
}
range specification, note that min <= max
func (*Int64Range) NextMedian ¶
func (ir *Int64Range) NextMedian() int64
get next median value within the interval including min and max
func (*Int64Range) NextRandom ¶
func (ir *Int64Range) NextRandom(r *rand.Rand) int64
get next random value within the interval including min and max
type Normalizer ¶
type Normalizer[T Number] struct { // contains filtered or unexported fields }
func (*Normalizer[T]) Get ¶
func (p *Normalizer[T]) Get(v T) T
func (*Normalizer[T]) Update ¶
func (p *Normalizer[T]) Update(v T)
type Number ¶
type Number interface { constraints.Float | constraints.Integer }
Click to show internal directories.
Click to hide internal directories.