using System; using System.Collections; using System.Collections.Generic; namespace Yavsc.Abstract.IT { public class CharArray : List, IEnumerable, IList { public CharArray (char [] charArray) : base (charArray) { } public CharArray (IList word): base(word) { } public CharArray (IEnumerable word): base(word) { } public IList Aggregate(char other) { this.Add(other); return this; } IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } } public class CodeFromChars : List, ICode { public void AddLetter(IEnumerable letter) { var candide = new CharArray(letter); // TODO build new denied letters: compute the automate // and check it is determinised // Automate a = new Automate(); Add(candide); } public bool Validate() { // this is a n*n task throw new NotImplementedException(); } IEnumerator> IEnumerable>.GetEnumerator() { return GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } private class Automate { int State { get; set; } Dictionary> Transitions { get; set; } CodeFromChars Code { get; set; } void Compute(CharArray chars) { if (!Code.Contains(chars)) { State = -1; return; } if (!Transitions.ContainsKey(State)) { State = -2; return; } var states = Transitions[State]; int letter = Code.IndexOf(chars); if (!states.ContainsKey(letter)) { State = -3; return; } State = states[letter]; } } } }