0001 template <typename T, typename V> void inorder1(BNP<T> x, V& visit) { 0002 Stack<BNP<T>> S; 0003 while (x || !S.empty()) { //只要x非nullptr,或S仍非空 0004 for ( ; x; x = x->lc) S.push(x); //藤上节点便自顶而下入栈 0005 visit((x = S.pop())->data); x = x->rc; //取出并访问栈顶节点,再转向右子树 0006 } //while 0007 } //inorder1