Exemple #1
0
 /// <summary>
 /// Try for another solution, asking parent for new solution if necessary.
 /// </summary>
 /// <returns>Success</returns>
 public override bool TryNext()
 {
     if (index == -1 && !parent.TryNext())
     {
         return(false);      // Parent didn't have any solutions
     }
     index++;
     while (index == parent.Current.Children.Count)
     {
         // We've exhaused parent's Current children; ask parent for another solution
         index = 0;
         if (!parent.TryNext())
         {
             // Parent is depleted
             return(false);
         }
     }
     // Got one.
     Current        = parent.Current.Children[index];
     variable.Value = Current.Key;
     return(true);
 }
Exemple #2
0
        /// <summary>
        /// Attempts to find the next solution
        /// </summary>
        /// <returns>Success</returns>
        public override bool TryNext()
        {
            if (!done)
            {
                while (parent.TryNext())
                {
                    foreach (var c in parent.Current.Children)
                    {
                        if (c.Key.Equals(key))
                        {
                            Current = c;
                            return(true);
                        }
                    }
                }
                done = true;
            }

            return(false);
        }