# HG changeset patch # User cin # Date 1456867248 -10800 # Node ID 96681e9d0ceada08678f1df36e97c6fbdff87c0b # Parent b84cdbe82e7f4ff100b9b7feb3bbf935510866b3 sync diff -r b84cdbe82e7f -r 96681e9d0cea Implab/Automaton/DFATransitionTable.cs --- a/Implab/Automaton/DFATransitionTable.cs Mon Feb 29 18:41:01 2016 +0300 +++ b/Implab/Automaton/DFATransitionTable.cs Wed Mar 02 00:20:48 2016 +0300 @@ -4,14 +4,14 @@ using System.Linq; namespace Implab.Automaton { - public class DFATransitionTable : IDFATableBuilder { + public class DFATransitionTable : IDFATableBuilder { DFAStateDescriptior[] m_dfaTable; int m_stateCount; int m_symbolCount; int m_initialState; - readonly Dictionary m_finalStates = new Dictionary(); + readonly HashSet m_finalStates = new HashSet(); readonly HashSet m_transitions = new HashSet(); @@ -32,10 +32,10 @@ public bool IsFinalState(int s) { Safe.ArgumentInRange(s, 0, m_stateCount, "s"); - return m_finalStates.ContainsKey(s); + return m_dfaTable != null ? m_dfaTable[s].final : m_finalStates.Contains(s); } - public IEnumerable> FinalStates { + public IEnumerable FinalStates { get { return m_finalStates; } @@ -55,8 +55,8 @@ #endregion - protected virtual DFAStateDescriptior[] ConstructTransitionTable() { - var dfaTable = new DFAStateDescriptior[m_stateCount]; + protected virtual DFAStateDescriptior[] ConstructTransitionTable() { + var dfaTable = new DFAStateDescriptior[m_stateCount]; foreach (var pair in m_finalStates) { var idx = pair.Key; diff -r b84cdbe82e7f -r 96681e9d0cea Implab/Automaton/IDFATableBuilder.cs --- a/Implab/Automaton/IDFATableBuilder.cs Mon Feb 29 18:41:01 2016 +0300 +++ b/Implab/Automaton/IDFATableBuilder.cs Wed Mar 02 00:20:48 2016 +0300 @@ -1,22 +1,14 @@ using System; +using System.Collections.Generic; namespace Implab.Automaton { - public interface IDFATableBuilder : IDFATable { + public interface IDFATableBuilder : IDFATable, ICollection { /// /// Marks the state as final. /// /// State. void MarkFinalState(int state); - /// - /// Defines the transition from to - /// with input . - /// - /// S1. - /// S2. - /// Symbol. - void DefineTransition(int s1, int s2, int symbol); - void SetInitialState(int s); } diff -r b84cdbe82e7f -r 96681e9d0cea Implab/Automaton/IndexedAlphabetBase.cs --- a/Implab/Automaton/IndexedAlphabetBase.cs Mon Feb 29 18:41:01 2016 +0300 +++ b/Implab/Automaton/IndexedAlphabetBase.cs Wed Mar 02 00:20:48 2016 +0300 @@ -8,6 +8,11 @@ /// /// Indexed alphabet is the finite set of symbols where each symbol has a zero-based unique index. /// + /// + /// Indexed alphabets are usefull in bulting efficient translations from source alphabet + /// to the input alphabet of the automaton. It's assumed that the index to the symbol match + /// is well known and documented. + /// public abstract class IndexedAlphabetBase : IAlphabetBuilder { int m_nextId = 1; readonly int[] m_map;