예제 #1
0
        public Automata(DataTable dataTable)
        {
            int states  = dataTable.Rows.Count;
            int letters = dataTable.Columns.Count - 1;

            _states = new List <int>();
            for (int i = 0; i < states; ++i)
            {
                _states.Add(i);
            }

            _letters = String.Empty;
            for (int i = 0; i < letters; ++i)
            {
                _letters += Convert.ToChar('a' + i);
            }

            _transitions = new Dictionary <int, Dictionary <char, int> >(states);
            for (int i = 0, n = states; i < n; ++i)
            {
                Dictionary <char, int> temp = new Dictionary <char, int>(letters);
                _transitions.Add(i, temp);
                for (int j = 0, m = letters; j < m; ++j)
                {
                    temp.Add(Convert.ToChar('a' + j), Convert.ToInt32(dataTable.Rows[i][j + 1]));
                }
            }
            ListUniqueListPool = new CollectionPool <List <UniqueSortedListInt>, UniqueSortedListInt>(() => new List <UniqueSortedListInt>());
            UniqueListPool     = new CollectionPool <UniqueSortedListInt, int>(() => new UniqueSortedListInt());
        }
예제 #2
0
 public Automata(List <int> states, String letters, Dictionary <int, Dictionary <char, int> > transitions)
 {
     _states            = states;
     _letters           = letters;
     _transitions       = transitions;
     ListUniqueListPool = new CollectionPool <List <UniqueSortedListInt>, UniqueSortedListInt>(() => new List <UniqueSortedListInt>());
     UniqueListPool     = new CollectionPool <UniqueSortedListInt, int>(() => new UniqueSortedListInt());
 }