public class GeneralDeterministicFiniteAutomaton extends java.lang.Object implements DeterministicFiniteAutomaton
| Modifier and Type | Field and Description |
|---|---|
protected int |
alphabetSize |
protected short |
initialState |
protected java.lang.String |
label |
protected short[][] |
matrix
Stores the representation of this automaton.
|
| Constructor and Description |
|---|
GeneralDeterministicFiniteAutomaton(java.lang.String label,
int alphabetSize)
Constructs a DFA over a given alphabet from [0..alphabetSize) (exclusive)
without states.
|
GeneralDeterministicFiniteAutomaton(java.lang.String label,
int alphabetSize,
int matrixSize)
Constructs a DFA over a given alphabet from [0..alphabetSize) (exclusive)
without states.
|
| Modifier and Type | Method and Description |
|---|---|
short |
addState(boolean isInitial,
byte type,
boolean addSelfLoops)
Adds a new state to the matrix
|
void |
addTransition(short fromS,
short toS,
short label)
Add a transition from state fromS to state toS labeled with label
|
void |
complete()
Adds a single PV type state to which all other states can transition
using any label not currently in the DFA.
|
boolean |
equals(java.lang.Object o) |
short |
getInitialState()
Returns the initial state
|
java.lang.String |
getLabel() |
short |
getNextState(short currentState,
int label)
returns the new state after executing a transition with the given label
in currentState, or NOSTATE is no such new state exists.
|
byte |
getStateType(short state)
Returns the type of the state (PV, TV, PS, or TS)
|
int |
hashCode() |
boolean |
isAcceptingState(short state)
Returns true if the given state is an accepting state
|
boolean |
isAllowed(short currentState,
int label)
Checks if the transition with the given label is possible in the given
state
|
boolean |
isComplete()
Check if the automaton is complete, i.e.
|
void |
reduce()
Reduces the DFA to remove all permanently violated states by simply
removing all transitions into these states and then removing unreachable
states.
|
void |
removeTransition(short fromS,
short label)
Remove transition labeled with label from state fromS
|
void |
setInitialState(short state)
Sets the initial state
|
void |
setStateType(short state,
byte type) |
java.lang.String |
toString() |
protected final int alphabetSize
protected short[][] matrix
protected short initialState
protected final java.lang.String label
public GeneralDeterministicFiniteAutomaton(java.lang.String label,
int alphabetSize)
alphabetSize - public GeneralDeterministicFiniteAutomaton(java.lang.String label,
int alphabetSize,
int matrixSize)
alphabetSize - public short addState(boolean isInitial,
byte type,
boolean addSelfLoops)
DeterministicFiniteAutomatonaddState in interface DeterministicFiniteAutomatonpublic void addTransition(short fromS,
short toS,
short label)
DeterministicFiniteAutomatonaddTransition in interface DeterministicFiniteAutomatonpublic void removeTransition(short fromS,
short label)
DeterministicFiniteAutomatonremoveTransition in interface DeterministicFiniteAutomatonpublic short getNextState(short currentState,
int label)
DeterministicFiniteAutomatongetNextState in interface DeterministicFiniteAutomatonpublic boolean isAllowed(short currentState,
int label)
DeterministicFiniteAutomatonisAllowed in interface DeterministicFiniteAutomatonpublic short getInitialState()
DeterministicFiniteAutomatongetInitialState in interface DeterministicFiniteAutomatonpublic void setInitialState(short state)
DeterministicFiniteAutomatonsetInitialState in interface DeterministicFiniteAutomatonpublic boolean isAcceptingState(short state)
DeterministicFiniteAutomatonisAcceptingState in interface DeterministicFiniteAutomatonpublic void setStateType(short state,
byte type)
setStateType in interface DeterministicFiniteAutomatonpublic void reduce()
DeterministicFiniteAutomatonreduce in interface DeterministicFiniteAutomatonpublic void complete()
DeterministicFiniteAutomatoncomplete in interface DeterministicFiniteAutomatonpublic boolean isComplete()
DeterministicFiniteAutomatonisComplete in interface DeterministicFiniteAutomatonpublic byte getStateType(short state)
DeterministicFiniteAutomatongetStateType in interface DeterministicFiniteAutomatonpublic boolean equals(java.lang.Object o)
equals in interface DeterministicFiniteAutomatonequals in class java.lang.Objectpublic int hashCode()
hashCode in interface DeterministicFiniteAutomatonhashCode in class java.lang.Objectpublic java.lang.String toString()
toString in interface DeterministicFiniteAutomatontoString in class java.lang.Objectpublic java.lang.String getLabel()
getLabel in interface DeterministicFiniteAutomaton