0001 template <typename T> void List<T>::reverse() { //前后倒置 0002 if ( _size < 2 ) return; //平凡情况 0003 for ( ListNodePosi(T) p = header; p; p = p->pred ) //自前向后,依次 0004 swap ( p->pred, p->succ ); //交换各节点的前驱、后继指针 0005 swap ( header, trailer ); //头、尾节点互换 0006 }