public Automatfcg(Automatfcg automat) { name = automat.name; priority = automat.priority; alphabet = new HashSet <char>(automat.alphabet); setStates = new HashSet <int>(automat.setStates); startStates = new HashSet <int>(automat.startStates); finishStates = new HashSet <int>(automat.finishStates); Table = new Dictionary <int, List <HashSet <int> > >(); foreach (var i in automat.Table.Keys) { Table.Add(i, automat.Table[i]); } }
public Automatfcg CreateSimpleAutomat(HashSet <char> alphabet, ref int index) { Automatfcg automat = new Automatfcg(); //автомат для 1 символа automat.name = name; automat.priority = priority; automat.startStates = new HashSet <int>(); automat.setStates = new HashSet <int>(); automat.finishStates = new HashSet <int>(); automat.alphabet = new HashSet <char>(alphabet); automat.Table = new Dictionary <int, List <HashSet <int> > >(); automat.startStates.Add(index); automat.setStates.UnionWith(automat.startStates); index++; automat.finishStates.Add(index); index++; automat.setStates.UnionWith(automat.finishStates); List <HashSet <int> > list = new List <HashSet <int> >(); List <HashSet <int> > listEnd = new List <HashSet <int> >(); for (int j = 0; j < automat.alphabet.Count; j++) { list.Add(new HashSet <int> { automat.finishStates.ElementAt(0) }); listEnd.Add(new HashSet <int> { -1 }); } automat.Table.Add(automat.startStates.ElementAt(0), list); automat.Table.Add(automat.finishStates.ElementAt(0), listEnd); return(automat); }