diff Implab/Automaton/IndexedAlphabetBase.cs @ 164:ec35731ae299 ref20160224

Almost complete DFA refactoring
author cin
date Thu, 25 Feb 2016 02:11:13 +0300
parents 0526412bbb26
children 96681e9d0cea
line wrap: on
line diff
--- a/Implab/Automaton/IndexedAlphabetBase.cs	Wed Feb 24 20:12:52 2016 +0300
+++ b/Implab/Automaton/IndexedAlphabetBase.cs	Thu Feb 25 02:11:13 2016 +0300
@@ -9,8 +9,6 @@
     /// Indexed alphabet is the finite set of symbols where each symbol has a zero-based unique index.
     /// </summary>
     public abstract class IndexedAlphabetBase<T> : IAlphabetBuilder<T> {
-        public const int UNCLASSIFIED = 0;
-
         int m_nextId = 1;
         readonly int[] m_map;
 
@@ -31,7 +29,7 @@
 
         public int DefineSymbol(T symbol) {
             var index = GetSymbolIndex(symbol);
-            if (m_map[index] == UNCLASSIFIED)
+            if (m_map[index] == DFAConst.UNCLASSIFIED_INPUT)
                 m_map[index] = m_nextId++;
             return m_map[index];
         }
@@ -42,7 +40,7 @@
 
             foreach (var symbol in symbols) {
                 var index = GetSymbolIndex(symbol);
-                if (m_map[index] == UNCLASSIFIED)
+                if (m_map[index] == DFAConst.UNCLASSIFIED_INPUT)
                     m_map[GetSymbolIndex(symbol)] = m_nextId;
                 else
                     throw new InvalidOperationException(String.Format("Symbol '{0}' already in use", symbol));
@@ -52,10 +50,10 @@
 
         public List<T>[] CreateReverseMap() {
             return
-                Enumerable.Range(UNCLASSIFIED, Count)
+                Enumerable.Range(0, Count)
                     .Select(
                         i => InputSymbols
-                            .Where(x => i != UNCLASSIFIED && m_map[GetSymbolIndex(x)] == i)
+                        .Where(x => i != DFAConst.UNCLASSIFIED_INPUT && m_map[GetSymbolIndex(x)] == i)
                             .ToList()
                     )
                     .ToArray();
@@ -70,7 +68,7 @@
 
             foreach (var scl in classes) {
                 // skip if the supper class contains the unclassified element
-                if (scl.Contains(UNCLASSIFIED))
+                if (scl.Contains(DFAConst.UNCLASSIFIED_INPUT))
                     continue;
                 var range = new List<T>();
                 foreach (var cl in scl) {