コード例 #1
0
 public Clue AddClue(List <string> remainingFragments, string[] fullSet)
 {
     // If we are the last cluefragment, then just add the clue
     if (remainingFragments.Count == 1 && Clue == null)
     {
         Clue = new Clue(fullSet);
     }
     else
     {
         string seg;
         for (int i = 0; i < remainingFragments.Count; i++)
         {
             seg = remainingFragments[i];
             if (Children.ContainsKey(seg))
             {
                 remainingFragments.RemoveAt(i); return(Children[seg].AddClue(remainingFragments, fullSet));
             }
         }
         seg           = remainingFragments[0];
         Children[seg] = new ClueNode();
         remainingFragments.RemoveAt(0);
         return(Children[seg].AddClue(remainingFragments, fullSet));
     }
     return(Clue);
 }
コード例 #2
0
 public void AddDocument(string[] clueFragments, int currentIndex, Document doc)
 {
     // If we are the last cluefragment, then just add the doc
     if (clueFragments.Length - 1 == currentIndex)
     {
         References.Add(doc);    // Notice not checking existence, assumed not existing
     }
     else
     {
         if (Children.ContainsKey(clueFragments[currentIndex + 1]) == false)
         {
             Children[clueFragments[currentIndex + 1]] = new ClueNode();
         }
         Children[clueFragments[currentIndex + 1]].AddDocument(clueFragments, currentIndex + 1, doc);
     }
 }
コード例 #3
0
        /// <summary>
        /// Given a clue string, add it to current set
        /// Input clue stirng can be in any order (e.g. C-A-B)
        /// </summary>
        /// <param name="clueString"></param>
        public Clue Add(string clueString)
        {
            List <string> segments = ClueHelper.SeperateClueFragments(clueString);

            string[] fullSet = segments.ToArray();
            string   seg;

            for (int i = 0; i < segments.Count; i++)
            {
                seg = segments[i];
                if (CluesTree.ContainsKey(seg))
                {
                    segments.RemoveAt(i); return(CluesTree[seg].AddClue(segments, fullSet));
                }
            }
            seg            = segments[0];
            CluesTree[seg] = new ClueNode();
            segments.RemoveAt(0);
            return(CluesTree[seg].AddClue(segments, fullSet));
        }