Mercurial > pub > ImplabNet
comparison Implab/Automaton/MapAlphabet.cs @ 172:92d5278d1b10 ref20160224
Working on text scanner
author | cin |
---|---|
date | Mon, 14 Mar 2016 01:19:38 +0300 |
parents | 0f70905b4652 |
children | 0c3c69fe225b |
comparison
equal
deleted
inserted
replaced
171:0f70905b4652 | 172:92d5278d1b10 |
---|---|
36 public int DefineClass(IEnumerable<T> symbols, int cls) { | 36 public int DefineClass(IEnumerable<T> symbols, int cls) { |
37 Safe.ArgumentAssert(cls >= 0, "cls"); | 37 Safe.ArgumentAssert(cls >= 0, "cls"); |
38 Safe.ArgumentNotNull(symbols, "symbols"); | 38 Safe.ArgumentNotNull(symbols, "symbols"); |
39 | 39 |
40 m_nextCls = Math.Max(cls + 1, m_nextCls); | 40 m_nextCls = Math.Max(cls + 1, m_nextCls); |
41 symbols = symbols.Distinct(); | |
42 | 41 |
43 foreach (var symbol in symbols) | 42 foreach (var symbol in symbols) |
44 m_map[symbol] = cls; | 43 m_map[symbol] = cls; |
45 return cls; | 44 return cls; |
46 } | 45 } |
66 | 65 |
67 public bool Contains(T symbol) { | 66 public bool Contains(T symbol) { |
68 return m_supportUnclassified || m_map.ContainsKey(symbol); | 67 return m_supportUnclassified || m_map.ContainsKey(symbol); |
69 } | 68 } |
70 | 69 |
70 | |
71 public IEnumerable<T> GetSymbols(int cls) { | |
72 return m_map.Where(p => p.Value == cls).Select(p => p.Key); | |
73 } | |
71 #endregion | 74 #endregion |
72 } | 75 } |
73 } | 76 } |
74 | 77 |