Example #1
0
 /// <summary>Traverses a tree with a starting point node.</summary>
 /// <remarks>
 /// Traverses a tree with a starting point node.
 /// If there is no exact match for the starting node, the next higher will be taken.
 /// </remarks>
 public static void Traverse(Tree tree, Tree startingNode, ICancellableVisitor4 visitor
                             )
 {
     if (tree == null)
     {
         return;
     }
     tree.Traverse(startingNode, visitor);
 }
Example #2
0
 private bool Traverse(Tree startingNode, ICancellableVisitor4 visitor)
 {
     if (startingNode != null)
     {
         int cmp = Compare(startingNode);
         if (cmp < 0)
         {
             if (_subsequent != null)
             {
                 return(_subsequent.Traverse(startingNode, visitor));
             }
             return(true);
         }
         else
         {
             if (cmp > 0)
             {
                 if (_preceding != null)
                 {
                     if (!_preceding.Traverse(startingNode, visitor))
                     {
                         return(false);
                     }
                 }
             }
         }
     }
     else
     {
         if (_preceding != null)
         {
             if (!_preceding.Traverse(null, visitor))
             {
                 return(false);
             }
         }
     }
     if (!visitor.Visit(this))
     {
         return(false);
     }
     if (_subsequent != null)
     {
         if (!_subsequent.Traverse(null, visitor))
         {
             return(false);
         }
     }
     return(true);
 }
Example #3
0
		private bool Traverse(Tree startingNode, ICancellableVisitor4 visitor)
		{
			if (startingNode != null)
			{
				int cmp = Compare(startingNode);
				if (cmp < 0)
				{
					if (_subsequent != null)
					{
						return _subsequent.Traverse(startingNode, visitor);
					}
					return true;
				}
				else
				{
					if (cmp > 0)
					{
						if (_preceding != null)
						{
							if (!_preceding.Traverse(startingNode, visitor))
							{
								return false;
							}
						}
					}
				}
			}
			else
			{
				if (_preceding != null)
				{
					if (!_preceding.Traverse(null, visitor))
					{
						return false;
					}
				}
			}
			if (!visitor.Visit(this))
			{
				return false;
			}
			if (_subsequent != null)
			{
				if (!_subsequent.Traverse(null, visitor))
				{
					return false;
				}
			}
			return true;
		}
Example #4
0
		/// <summary>Traverses a tree with a starting point node.</summary>
		/// <remarks>
		/// Traverses a tree with a starting point node.
		/// If there is no exact match for the starting node, the next higher will be taken.
		/// </remarks>
		public static void Traverse(Tree tree, Tree startingNode, ICancellableVisitor4 visitor
			)
		{
			if (tree == null)
			{
				return;
			}
			tree.Traverse(startingNode, visitor);
		}