Exemplo n.º 1
0
        public void TriTest(string wordFilePath)
        {
            WordFileWrapper wfw   = new WordFileWrapper(wordFilePath);
            Tri             myTri = new Tri(wfw.GetAllWords());
            TriNavigator    nav   = myTri.GetNavigator();

            var x = 5;
        }
Exemplo n.º 2
0
        public static HashSet <string> WordsInCharBuffer(char[] carr, Tri possibleWords)
        {
            HashSet <string> retStore = new HashSet <string>();

            for (long i = 0; i < carr.Length; i++)
            {
                TriNavigator nav          = possibleWords.GetNavigator();
                long         initalLength = 1;
                string       initialStr   = "";
                RecurseFromCurrent(carr, i, initalLength, nav, initialStr, retStore);
            }
            return(retStore);
        }
Exemplo n.º 3
0
 public static void RecurseFromCurrent(char[] carr, long curIndex, long curLength, TriNavigator nav, string curStr, HashSet<string> retStore)
 {
     if((curLength + curIndex) > carr.Length) { return; }
     if (!nav.CanMoveTo(carr[curIndex + curLength - 1]))
     {
         return;
     }
     curStr += carr[curIndex + curLength - 1];
     nav.MoveTo(carr[curIndex + curLength - 1]);
     if (nav.CanFinishPath())
     {
         retStore.Add(curStr);
     }
     if (nav.HasNonTerminatingChildren())
     {
         RecurseFromCurrent(carr, curIndex, ++curLength, nav, curStr, retStore);
     }
 }
Exemplo n.º 4
0
 public static void RecurseFromCurrent(char[] carr, long curIndex, long curLength, TriNavigator nav, string curStr, HashSet <string> retStore)
 {
     if ((curLength + curIndex) > carr.Length)
     {
         return;
     }
     if (!nav.CanMoveTo(carr[curIndex + curLength - 1]))
     {
         return;
     }
     curStr += carr[curIndex + curLength - 1];
     nav.MoveTo(carr[curIndex + curLength - 1]);
     if (nav.CanFinishPath())
     {
         retStore.Add(curStr);
     }
     if (nav.HasNonTerminatingChildren())
     {
         RecurseFromCurrent(carr, curIndex, ++curLength, nav, curStr, retStore);
     }
 }