transition

package
v0.0.0-...-a26ebea Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2022 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrTableMustBeSet = validation.NewError(
	"transitions_table_must_be_set",
	"the transitions table must be set and cannot be an empty",
)

ErrTableMustBeSet is the validation check error returned when the transitions table is empty.

Functions

This section is empty.

Types

type Table

type Table[T state.State] map[T]map[T]bool

Table represents a nested map for storing states and their valid transitions.

type Transitions

type Transitions[T state.State] struct {
	// contains filtered or unexported fields
}

Transitions represents a structure for describing states and the valid transitions between them.

func Generate

func Generate[T state.State](rand *rand.Rand, states []T) *Transitions[T]

Generate from a set of random states.

func New

func New[T state.State](transitions Table[T]) (*Transitions[T], validation.ErrorGroup)

New creates and validates a new Transitions.

func (*Transitions[T]) Check

func (t *Transitions[T]) Check() validation.ErrorGroup

Check runs default validation checks for the Transitions.

func (Transitions[T]) Generate

func (Transitions[T]) Generate(rand *rand.Rand, size int) reflect.Value

Generate random Transition values.

Interface: quick.Generator

func (*Transitions[T]) Len

func (t *Transitions[T]) Len() int

Len returns number of registered transitions for all states.

func (*Transitions[T]) Valid

func (t *Transitions[T]) Valid(current, next T) bool

Valid return true for registered transition between current -> next states.

Jump to

Keyboard shortcuts

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