private void populateTable(string url) { Table = new LookupWordTable(); List <string> uniqueWords = getUniqueWords(url); foreach (string uniqueWord in uniqueWords) { LookupLetterTable letterTable = new LookupLetterTable(); foreach (char letter in uniqueWord) { if (!letterTable.ContainsKey(letter)) { List <string> intersectingWords = new List <string>(); foreach (string word in uniqueWords) { if (word.IndexOf(letter) > -1) { if (!intersectingWords.Contains(word)) { intersectingWords.Add(word); } } } letterTable.Add(letter, intersectingWords); } } Table.Add(uniqueWord, letterTable); } }
public List <string> GetIntersections(string word, char letter) { List <string> words = new List <string>(); if (Table.ContainsKey(word)) { LookupLetterTable letterTable = Table[word]; if (letterTable.ContainsKey(letter)) { words = letterTable[letter]; } } return(words); }