DummyAlphabet.cs
46 lines
| 1.2 KiB
| text/x-csharp
|
CSharpLexer
|
|
r163 | using System; | ||
| using System.Collections.Generic; | ||||
| using System.Linq; | ||||
| namespace Implab.Automaton { | ||||
|
|
r164 | /// <summary> | ||
| /// Dummy alphabet consists of integer numbers which are identical to their classes. | ||||
| /// </summary> | ||||
|
|
r163 | public class DummyAlphabet : IAlphabet<int> { | ||
| readonly int m_size; | ||||
|
|
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> | ||||
|
|
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(); | ||||
| } | ||||
|
|
r171 | public int Translate(int symbol) { | ||
| Safe.ArgumentInRange(symbol, 0, m_size, "symbol"); | ||||
| return symbol; | ||||
|
|
r163 | } | ||
|
|
r171 | public bool Contains(int symbol) { | ||
| Safe.ArgumentInRange(symbol, 0, m_size, "symbol"); | ||||
| return true; | ||||
|
|
r163 | } | ||
| public int Count { | ||||
| get { | ||||
| return m_size; | ||||
| } | ||||
| } | ||||
| #endregion | ||||
| } | ||||
| } | ||||
