Exemplo n.º 1
0
        ///<summary>
        /// Determine order, walk the tree and push the nodes onto the stack
        ///</summary>
        public RedBlackEnumerator(RedBlack redBlack, RedBlackNode tnode, bool keys, bool ascending)
        {
            this.stack     = new Stack();
            this.keys      = keys;
            this.ascending = ascending;
            this.redBlack  = redBlack;

            // use depth-first traversal to push nodes into stack
            // the lowest node will be at the top of the stack
            if (ascending)
            {               // find the lowest node
                while (tnode != redBlack.sentinelNode)
                {
                    stack.Push(tnode);
                    tnode = tnode.Left;
                }
            }
            else
            {
                // the highest node will be at top of stack
                while (tnode != redBlack.sentinelNode)
                {
                    stack.Push(tnode);
                    tnode = tnode.Right;
                }
            }
        }
Exemplo n.º 2
0
		///<summary>
		/// Determine order, walk the tree and push the nodes onto the stack
		///</summary>
		public RedBlackEnumerator(RedBlack redBlack, RedBlackNode tnode, bool keys, bool ascending) 
        {

            this.stack = new Stack();
            this.keys = keys;
            this.ascending = ascending;
            this.redBlack = redBlack;
			
            // use depth-first traversal to push nodes into stack
            // the lowest node will be at the top of the stack
            if(ascending)
			{   // find the lowest node
                while (tnode != redBlack.sentinelNode)
				{
					stack.Push(tnode);
					tnode = tnode.Left;
				}
			}
			else
			{
                // the highest node will be at top of stack
                while (tnode != redBlack.sentinelNode)
				{
					stack.Push(tnode);
					tnode = tnode.Right;
				}
			}
			
		}