0001 #include "list/list.h" 0002 0003 template <typename T> void checkOrder( List<T>& L ) { //判断列表是否整体有序 0004 int nInv = 0; //逆序计数器 0005 L.traverse( CheckOrder<T>( nInv, L.first()->data ) ); //进行遍历 0006 if ( 0 < nInv ) 0007 printf( "Unsorted with %d adjacent inversion(s)\n", nInv ); 0008 else 0009 printf( "Sorted\n" ); 0010 }