private WordTable GetIntersectingWords(WordList list) { IntersectingWords = new WordTable(); LetterTable letterTable = new LetterTable(); foreach (char letter in Element) { if (!letterTable.ContainsKey(letter)) { List <string> intersectingWords = new List <string>(); foreach (string w in list.aWordList) { if (w.IndexOf(letter) > -1) { if (!intersectingWords.Contains(w)) { intersectingWords.Add(w); } } } letterTable.Add(letter, intersectingWords); } } IntersectingWords.Add(Element, letterTable); return(IntersectingWords); }
private void PopulateTable(string path) { Table = new WordTable(); List <string> words = GetWords(path); foreach (string word in words) { LetterTable letterTable = new LetterTable(); foreach (char letter in word) { if (!letterTable.ContainsKey(letter)) { List <string> intersectingWords = new List <string>(); foreach (string w in words) { if (w.IndexOf(letter) > -1) { if (!intersectingWords.Contains(w)) { intersectingWords.Add(w); } } } letterTable.Add(letter, intersectingWords); } } Table.Add(word, letterTable); } }
private void PopulateTable() { //create dict Table = new WordTable(); List <string> words = GetWords(); //List<string> words = new List<string>(); //words.Add("ANGELA"); //words.Add("JIMMY"); //words.Add("LARRY"); //words.Add("JACK"); //words.Add("JILL"); //words.Add("MARK"); //words.Add("AMY"); foreach (string word in words) { LetterTable letterTable = new LetterTable(); foreach (char letter in word) { if (!letterTable.ContainsKey(letter)) { List <string> intersectingWords = new List <string>(); foreach (string w in words) { if (w.IndexOf(letter) > -1) { if (!intersectingWords.Contains(w)) { intersectingWords.Add(w); } } } letterTable.Add(letter, intersectingWords); } } Table.Add(word, letterTable); } }