constraints

package
v0.22.0-rc.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrMinMaxConstraint = errors.New("min constraint cannot be greater than max constraint")

ErrMinMaxConstraint custom error.

Functions

This section is empty.

Types

type ConstraintType

type ConstraintType int

ConstraintType indicates the type of constraint.

const (
	// None indicates no constraint.
	None ConstraintType = iota
	// MinConstraint indicates min constraint.
	MinConstraint
	// MaxConstraint indicates max constraint.
	MaxConstraint
)

type MinMaxConstraints

type MinMaxConstraints struct {
	Max float64
	Min float64
}

MinMaxConstraints grouping constraints.

func NewMinMaxConstraints

func NewMinMaxConstraints() *MinMaxConstraints

NewMinMaxConstraints Default to largest float64 for max and smallest float64 for min.

func (*MinMaxConstraints) Constrain

func (mmc *MinMaxConstraints) Constrain(value float64) (float64, ConstraintType)

Constrain sets constraints.

func (*MinMaxConstraints) GetMax

func (mmc *MinMaxConstraints) GetMax() float64

GetMax returns max.

func (*MinMaxConstraints) GetMin

func (mmc *MinMaxConstraints) GetMin() float64

GetMin returns min.

func (*MinMaxConstraints) SetMax

func (mmc *MinMaxConstraints) SetMax(max float64) error

SetMax update max constraint if current max constraint is greater than provided max.

func (*MinMaxConstraints) SetMin

func (mmc *MinMaxConstraints) SetMin(min float64) error

SetMin update min constraint if current min constraint is less than provided min.

Jump to

Keyboard shortcuts

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