Package util

Class TransitionTable

java.lang.Object
util.TransitionTable
All Implemented Interfaces:
Configuration

public class TransitionTable extends Object implements Configuration
The transition table is implemented by a hash map of hash maps. It defines the behavior of the DFSA and is one of the five-tuple expected by the FSM constructor.
Author:
Krish Pillai
See Also:
  • Constructor Details

    • TransitionTable

      public TransitionTable(State[] states, String[] actions, State[][] transitions)
      Each entry of this associative array is an associative array indexed by actions. This enables the delta function for a specific state and action to be obtained in constant time. Each row is indexed by state, in the order defined by the state array. And each column is indexed by the action, in the order defined in the actions array.
      Parameters:
      states - Array of states
      actions - Array of actions
      transitions - The transition table
      See Also:
  • Method Details

    • contains

      public boolean contains(State s)
      Checks if the specified state is defined for this FSM
      Parameters:
      s - The state entry in the transition table
      Returns:
      boolean indicating presence
    • getInitialState

      public State getInitialState()
      Gets the initial state of this transition table. There can be only one initial state.
      Returns:
      the initial state
    • getFinalStates

      public State[] getFinalStates()
      Returns an array containing the final states for this FSM. The DFSA can have multiple final states.
      Returns:
      the final state
      See Also:
    • delta

      public State delta(State q, String a)
      Evaluates the delta function delta(q, a), where 'q' is the current state and 'a' is the action
      Parameters:
      q - The current state
      a - The input to the FSM
      Returns:
      state The next state according to the transition table
      See Also:
    • hasAction

      public boolean hasAction(String action)
      Checks if the action is valid and defined for this DFSA.
      Parameters:
      action - The action in question
      Returns:
      true or false