algorithm.temp.h
Go to the documentation of this file.00001
00017 #ifndef CTL_ALGORITHM_TEMP_H
00018 #define CTL_ALGORITHM_TEMP_H
00019
00025 #define ctl_array_qsort_implement(type)\
00026 ctl_array_qsort_declare(type)\
00027 {\
00028 if ( high > low )\
00029 {\
00030 type* scanlow = low;\
00031 type* scanhigh = high;\
00032 {\
00033 type* middle = low + ((high - low)>>1);\
00034 while( scanlow <= scanhigh )\
00035 {\
00036 while( ( scanlow < high ) && ( compare( scanlow, middle ) < 0 ) )\
00037 ++scanlow;\
00038 while( ( scanhigh > low ) && ( compare( scanhigh, middle ) > 0 ) )\
00039 --scanhigh;\
00040 if( scanlow <= scanhigh ) \
00041 {\
00042 ppConcat( type,_swap )( scanlow, scanhigh );\
00043 if( middle == scanlow )\
00044 middle = scanhigh;\
00045 else if( middle == scanhigh )\
00046 middle = scanlow;\
00047 ++scanlow;\
00048 --scanhigh;\
00049 }\
00050 }\
00051 }\
00052 if( low < scanhigh )\
00053 ppConcat(type,_array_qsort)( low, scanhigh, compare );\
00054 if( scanlow < high )\
00055 ppConcat(type,_array_qsort)( scanlow, high, compare );\
00056 }\
00057 }
00058
00064 #define ctl_array_bsort_implement(type)\
00065 ctl_array_bsort_declare(type)\
00066 {\
00067 bool bSwap;\
00068 do\
00069 {\
00070 bSwap = false;\
00071 while( low < high )\
00072 {\
00073 if( compare( low,low+1 ) > 0 )\
00074 {\
00075 ppConcat( type,_swap )( low,low+1 );\
00076 bSwap = true;\
00077 }\
00078 low++;\
00079 }\
00080 } while( bSwap );\
00081 }
00082
00083
00084 #endif