##// END OF EJS Templates
sync
sync

File last commit:

r164:ec35731ae299 ref20160224
r168:8fb9c9507a26 ref20160224
Show More
DummyAlphabet.cs
56 lines | 1.6 KiB | text/x-csharp | CSharpLexer
cin
JSON moved to Formats namespace...
r163 using System;
using System.Collections.Generic;
using System.Linq;
namespace Implab.Automaton {
cin
Almost complete DFA refactoring
r164 /// <summary>
/// Dummy alphabet consists of integer numbers which are identical to their classes.
/// </summary>
cin
JSON moved to Formats namespace...
r163 public class DummyAlphabet : IAlphabet<int> {
readonly int m_size;
cin
Almost complete DFA refactoring
r164
/// <summary>
/// Creates a new dummy alphabet with given size.
/// </summary>
/// <param name="size">The size of the alphabet, must be greater then zero.</param>
cin
JSON moved to Formats namespace...
r163 public DummyAlphabet(int size) {
Safe.ArgumentAssert(size > 0);
m_size = 0;
}
#region IAlphabet implementation
public List<int>[] CreateReverseMap() {
Enumerable.Range(0, m_size).ToArray();
}
public int[] Reclassify(IAlphabetBuilder<int> newAlphabet, IEnumerable<IEnumerable<int>> classes) {
Safe.ArgumentNotNull(newAlphabet, "newAlphabet");
Safe.ArgumentNotNull(classes, "classes");
var map = new int[m_size];
foreach (var cls in classes) {
cin
Almost complete DFA refactoring
r164 if (cls.Contains(DFAConst.UNCLASSIFIED_INPUT))
continue;
cin
JSON moved to Formats namespace...
r163 var newid = newAlphabet.DefineClass(cls);
foreach (var id in cls)
map[id] = newid;
}
return map;
}
public int Translate(int symobl) {
Safe.ArgumentInRange(symobl, 0, m_size, "symbol");
return symobl;
}
public int Count {
get {
return m_size;
}
}
#endregion
}
}