0001 template <typename T> BinNodePosi<T> BST<T>::insert( const T& e ) { //将关键码e插入BST树中 0002 BinNodePosi<T>& x = search( e ); //通过查找 0003 if ( x ) return x; //确认目标不存在,并设置_hot 0004 x = new BinNode<T>( e, _hot ); //在x处创建新节点,以_hot为父 0005 _size++; //更新全树规模 0006 x->updateHeightAbove(); //更新x及其历代祖先的高度 0007 return x; //新插入的节点,必为叶子 0008 } //无论e是否存在于原树中,返回时总有x->data == e