Mercurial > pub > ImplabNet
comparison Implab/Automaton/DFATransitionTable.cs @ 165:e227e78d72e4 ref20160224
DFA refactoring
| author | cin |
|---|---|
| date | Mon, 29 Feb 2016 02:02:17 +0300 |
| parents | ec35731ae299 |
| children | 96681e9d0cea |
comparison
equal
deleted
inserted
replaced
| 164:ec35731ae299 | 165:e227e78d72e4 |
|---|---|
| 2 using System; | 2 using System; |
| 3 using System.Collections.Generic; | 3 using System.Collections.Generic; |
| 4 using System.Linq; | 4 using System.Linq; |
| 5 | 5 |
| 6 namespace Implab.Automaton { | 6 namespace Implab.Automaton { |
| 7 public class DFATransitionTable<TTag> : IDFATransitionTableBuilder<TTag> { | 7 public class DFATransitionTable<TTag> : IDFATableBuilder { |
| 8 DFAStateDescriptior<TTag>[] m_dfaTable; | 8 DFAStateDescriptior[] m_dfaTable; |
| 9 | 9 |
| 10 int m_stateCount; | 10 int m_stateCount; |
| 11 int m_symbolCount; | 11 int m_symbolCount; |
| 12 int m_initialState; | 12 int m_initialState; |
| 13 | 13 |
| 15 readonly HashSet<AutomatonTransition> m_transitions = new HashSet<AutomatonTransition>(); | 15 readonly HashSet<AutomatonTransition> m_transitions = new HashSet<AutomatonTransition>(); |
| 16 | 16 |
| 17 | 17 |
| 18 #region IDFADefinition implementation | 18 #region IDFADefinition implementation |
| 19 | 19 |
| 20 public DFAStateDescriptior<TTag>[] GetTransitionTable() { | 20 public DFAStateDescriptior[] GetTransitionTable() { |
| 21 if (m_dfaTable == null) { | 21 if (m_dfaTable == null) { |
| 22 if (m_stateCount <= 0) | 22 if (m_stateCount <= 0) |
| 23 throw new InvalidOperationException("Invalid automaton definition: states count = {0}", m_stateCount); | 23 throw new InvalidOperationException("Invalid automaton definition: states count = {0}", m_stateCount); |
| 24 if (m_symbolCount <= 0) | 24 if (m_symbolCount <= 0) |
| 25 throw new InvalidOperationException("Invalid automaton definition: symbols count = {0}", m_symbolCount); | 25 throw new InvalidOperationException("Invalid automaton definition: symbols count = {0}", m_symbolCount); |
| 106 | 106 |
| 107 | 107 |
| 108 #endregion | 108 #endregion |
| 109 | 109 |
| 110 protected void Optimize<TInput, TState>( | 110 protected void Optimize<TInput, TState>( |
| 111 IDFATransitionTableBuilder<TTag> optimalDFA, | 111 IDFATableBuilder<TTag> optimalDFA, |
| 112 IAlphabet<TInput> inputAlphabet, | 112 IAlphabet<TInput> inputAlphabet, |
| 113 IAlphabetBuilder<TInput> optimalInputAlphabet, | 113 IAlphabetBuilder<TInput> optimalInputAlphabet, |
| 114 IAlphabet<TState> stateAlphabet, | 114 IAlphabet<TState> stateAlphabet, |
| 115 IAlphabetBuilder<TState> optimalStateAlphabet | 115 IAlphabetBuilder<TState> optimalStateAlphabet |
| 116 ) { | 116 ) { |
