0001 #include "vector/vector.h" 0002 0003 template <typename T> void checkOrder ( Vector<T> & V ) { //判断向量是否整体有序 0004 int unsorted = 0; //逆序计数器 0005 V.traverse ( CheckOrder<T> ( unsorted, V[0] ) ); //进行遍历 0006 if ( 0 < unsorted ) 0007 printf ( "Unsorted with %d adjacent disordered pair(s)\n", unsorted ); 0008 else 0009 printf ( "Sorted\n" ); 0010 } 0011 0012 //template <typename T> void checkOrder(Vector<T> & V) { 0013 // if (0 < V.disordered()) 0014 // printf("Unsorted with %d adjacent disordered pair(s)\n", V.disordered()); 0015 // else 0016 // printf("Sorted\n"); 0017 //}