/* How many transitions this state has. */
556911
func (a *Automaton) numTransitions(state int) int {
	if count := a.states[2*state+1]; count != -1 {
		return count
	}
	return 0
}
308493
func (wd *WaitDelay) AdjacentStates() []MachineState {
	if wd.next == nil {
		return nil
	}
	return []MachineState{wd.next}
}
1253546
func (f *FSM) Transition() error {
	f.eventMu.Lock()
	defer f.eventMu.Unlock()
	return f.doTransition()
}
1136260
func NewState() *State {
	return &State{
		store:                        store.NewNilStore(),
		monitor:                      monitor.NewNilMonitor(),
		invokeGlobalCallbacksOnFlush: true,
	}
}
484891
func Transition(toState string) Decider {
	return func(ctx *FSMContext, h *swf.HistoryEvent, data interface{}) Outcome {
		logf(ctx, "at=transition")
		return ctx.Goto(toState, data, ctx.EmptyDecisions())
	}
}
597018
func init() {
	lbls := make([]lingo.DependencyType, lingo.MAXDEPTYPE)

	for i := 0; i < int(lingo.MAXDEPTYPE); i++ {
		lbls[i] = lingo.DependencyType(i)
	}

	transitions = buildTransitions(lbls)
	MAXTRANSITION = len(transitions)
}
353272
func (a *Automaton) sortedTransitions() [][]*Transition {
	numStates := a.numStates()
	transitions := make([][]*Transition, numStates)
	for s := 0; s < numStates; s++ {
		numTransitions := a.numTransitions(s)
		transitions[s] = make([]*Transition, numTransitions)
		for t := 0; t < numTransitions; t++ {
			transition := newTransition()
			a.transition(s, t, transition)
			transitions[s][t] = transition
		}
	}
	return transitions
}
943224
func (wu *WaitUntil) AdjacentStates() []MachineState {
	if wu.next == nil {
		return nil
	}
	return []MachineState{wu.next}
}
1290643
func (xc *CommonExchange) state() *ExchangeState {
	xc.mtx.RLock()
	defer xc.mtx.RUnlock()
	return xc.currentState
}
771791
func stateStepsFor231() []Step {
	return []Step{
		&upgradeStep{
			description: "add status to relations",
			targets:     []Target{DatabaseMaster},
			run: func(context Context) error {
				return context.State().AddRelationStatus()
			},
		},
	}
}
936444
func (s *Execution_State) Evolve(newState Execution_State) error {
	nextStates := validExecutionStateEvolution[*s]
	if nextStates == nil {
		return fmt.Errorf("invalid state transition: no transitions defined for %s", *s)
	}

	if newState == *s {
		return nil
	}

	for _, val := range nextStates {
		if newState == val {
			*s = newState
			return nil
		}
	}

	return fmt.Errorf("invalid state transition %v -> %v", *s, newState)
}
1334083
func state0(s *scanner, c int) int {
	if c == '.' {
		s.step = stateDot
		return scanContinue
	}
	if c == 'e' || c == 'E' {
		s.step = stateE
		return scanContinue
	}
	return stateEndValue(s, c)
}
1177876
func NewStateAlloc(f Alloc) *State {
	ls := C.clua_newstate(unsafe.Pointer(&f))
	return newState(ls)
}
136787
func stateGreater(a, b state) bool {
	switch a {
	case stateIncreaseRate:
		return false
	case stateDecreaseAndGuessRate:
		return b == stateIncreaseRate
	case stateEmergency:
		return b == stateIncreaseRate || b == stateDecreaseAndGuessRate
	default:
		panic(fmt.Sprintf("BUG: cannot compare states: %v and %v", a, b))
	}
}
896807
func (a *Automaton) addTransition(source, dest, label int) {
	a.addTransitionRange(source, dest, label, label)
}
160155
func (s *Scanner) popParseState() {
	n := len(s.parseState) - 1
	s.parseState = s.parseState[0:n]
	s.redo = false
	if n == 0 {
		s.Step = stateEndTop
		s.endTop = true
	} else {
		s.Step = stateEndValue
	}
}
711649
func (s *Stream) State() State {
	s.l.Lock()
	defer s.l.Unlock()
	return s.state
}