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