163
|
1 using System;
|
|
2 using System.Collections.Generic;
|
|
3 using System.Linq;
|
|
4
|
|
5 namespace Implab.Automaton {
|
|
6 public class DummyAlphabet : IAlphabet<int> {
|
|
7 readonly int m_size;
|
|
8 public DummyAlphabet(int size) {
|
|
9 Safe.ArgumentAssert(size > 0);
|
|
10 m_size = 0;
|
|
11 }
|
|
12
|
|
13 #region IAlphabet implementation
|
|
14
|
|
15 public List<int>[] CreateReverseMap() {
|
|
16 Enumerable.Range(0, m_size).ToArray();
|
|
17 }
|
|
18
|
|
19 public int[] Reclassify(IAlphabetBuilder<int> newAlphabet, IEnumerable<IEnumerable<int>> classes) {
|
|
20 Safe.ArgumentNotNull(newAlphabet, "newAlphabet");
|
|
21 Safe.ArgumentNotNull(classes, "classes");
|
|
22 var map = new int[m_size];
|
|
23 foreach (var cls in classes) {
|
|
24 var newid = newAlphabet.DefineClass(cls);
|
|
25 foreach (var id in cls)
|
|
26 map[id] = newid;
|
|
27 }
|
|
28
|
|
29 return map;
|
|
30 }
|
|
31
|
|
32 public int Translate(int symobl) {
|
|
33 Safe.ArgumentInRange(symobl, 0, m_size, "symbol");
|
|
34 return symobl;
|
|
35 }
|
|
36
|
|
37 public int Count {
|
|
38 get {
|
|
39 return m_size;
|
|
40 }
|
|
41 }
|
|
42
|
|
43 #endregion
|
|
44 }
|
|
45 }
|
|
46
|