public void Init() { for (int i = 0; i < Template.Length; i++) { // add in template characters char ch = Template[i]; if (Elems.ContainsKey(ch)) { Elems[ch]++; } else { Elems.Add(ch, 1); } } // add in pairs for (int i = 0; i < Template.Length - 1; i++) { var key = Template.Substring(i, 2); if (Pairs.ContainsKey(key)) { Pairs[key]++; } else { Pairs.Add(key, 1); } } }
public void AddFrom(MfModelDicts dict) { foreach (var c in dict.Cates) { if (!Cates.ContainsKey(c.Key)) { Cates.Add(c.Key, c.Value); } } foreach (var c in dict.Elems) { if (!Elems.ContainsKey(c.Key)) { Elems.Add(c.Key, c.Value); } } foreach (var c in dict.Fams) { if (!Fams.ContainsKey(c.Key)) { Fams.Add(c.Key, c.Value); } } foreach (var c in dict.Floors) { if (!Floors.ContainsKey(c.Key)) { Floors.Add(c.Key, c.Value); } } foreach (var c in dict.Mats) { if (!Mats.ContainsKey(c.Key)) { Mats.Add(c.Key, c.Value); } } foreach (var c in dict.Types) { if (!Types.ContainsKey(c.Key)) { Types.Add(c.Key, c.Value); } } foreach (var c in dict.Views) { if (!Views.ContainsKey(c.Key)) { Views.Add(c.Key, c.Value); } } }
public void PairInsertion() { NewPairs = new Dictionary <string, long>(); foreach (var pair in Pairs) { char ch = Converter[pair.Key][0]; if (Elems.ContainsKey(ch)) { Elems[ch] += pair.Value; } else { Elems.Add(ch, pair.Value); } AddNewPair($"{pair.Key[0]}{ch}", pair.Value); AddNewPair($"{ch}{pair.Key[1]}", pair.Value); } Pairs = NewPairs; }