intrange

package
v3.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package intrange provides distributions that return ints.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Infinite

type Infinite struct{}

Infinite is a immutable range which always polls math.MaxInt32

func (Infinite) EnforceRange

func (inf Infinite) EnforceRange(i int) int

EnforceRange for an Infinite returns Infinite

func (Infinite) Mult

func (inf Infinite) Mult(i float64) Range

Mult does nothing to Infinites.

func (Infinite) Percentile

func (inf Infinite) Percentile(float64) int

Percentile can only return math.MaxInt32

func (Infinite) Poll

func (inf Infinite) Poll() int

Poll returns math.MaxInt32 on Infinites.

type Range

type Range interface {
	Poll() int
	Mult(float64) Range
	EnforceRange(int) int
	Percentile(float64) int
}

Range represents a range of integer numbers

func NewConstant

func NewConstant(i int) Range

NewConstant returns a range which will always return the input constant

func NewInfinite

func NewInfinite() Range

NewInfinite returns a range which will always return math.MaxInt32 and is unchangeable.

func NewLinear

func NewLinear(min, max int) Range

NewLinear returns a linear range between min and max

func NewSpread

func NewSpread(base, spread int) Range

NewSpread returns a linear range from base - s to base + s

Jump to

Keyboard shortcuts

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