0001 template <typename T> //将e插入至[r] 0002 Rank Vector<T>::insert ( Rank r, T const & e ) { //0 <= r <= size 0003 //print( e ); 0004 expand(); //如必要,先扩容 0005 for ( Rank i = _size; r < i; i-- ) //自后向前,后继元素 0006 _elem[i] = _elem[i-1]; //顺次后移一个单元 0007 _elem[r] = e; _size++; //置入新元素并更新容量 0008 return r; //返回秩 0009 }