예제 #1
0
        public bool Move()
        {
            if (state == 0)
            {
                if (root.Left != null)
                {
                    state = 1;
                    it    = new BSTInOrderIterator <T>(root.Left);
                }
                else
                {
                    state = 2;
                    return(true);
                }
            }
            if (state == 1)
            {
                if (!it.Move())
                {
                    state = 2;
                    return(true);
                }
            }
            if (state == 2)
            {
                if (root.Right != null)
                {
                    state = 3;
                    it    = new BSTInOrderIterator <T>(root.Right);
                }
                else
                {
                    return(false);
                }
            }
            if (state == 3)
            {
                if (!it.Move())
                {
                    state = 4;
                }
            }
            if (state == 4)
            {
                return(false);
            }

            return(true);
        }
예제 #2
0
 public void Reset()
 {
     it    = null;
     state = 0;
 }