0001 #include "listNode.h" 0002 template <typename T> int List<T>::disordered() const { //统计逆序相邻元素对的总数 0003 int n = 0; ListNode<T>* p = first(); 0004 for ( int i = 0; i < _size - 1; p = p->succ, i++ ) 0005 if ( p->data > p->succ->data ) n++; 0006 return n; 0007 }