equal
deleted
inserted
replaced
63 |
63 |
64 #define Q_FIXED_POINT_SCALE 32 |
64 #define Q_FIXED_POINT_SCALE 32 |
65 |
65 |
66 // Quick sort. |
66 // Quick sort. |
67 template <class T, class LessThan> |
67 template <class T, class LessThan> |
|
68 #ifdef Q_CC_RVCT // RVCT 2.2 doesn't see recursive _static_ template function |
|
69 void sort(T *array, int count, LessThan lessThan) |
|
70 #else |
68 static void sort(T *array, int count, LessThan lessThan) |
71 static void sort(T *array, int count, LessThan lessThan) |
|
72 #endif |
69 { |
73 { |
70 // If the number of elements fall below some threshold, use insertion sort. |
74 // If the number of elements fall below some threshold, use insertion sort. |
71 const int INSERTION_SORT_LIMIT = 7; // About 7 is fastest on my computer... |
75 const int INSERTION_SORT_LIMIT = 7; // About 7 is fastest on my computer... |
72 if (count <= INSERTION_SORT_LIMIT) { |
76 if (count <= INSERTION_SORT_LIMIT) { |
73 for (int i = 1; i < count; ++i) { |
77 for (int i = 1; i < count; ++i) { |
120 sort(array + low + 1, count - low - 1, lessThan); |
124 sort(array + low + 1, count - low - 1, lessThan); |
121 } |
125 } |
122 |
126 |
123 // Quick sort. |
127 // Quick sort. |
124 template <class T> |
128 template <class T> |
|
129 #ifdef Q_CC_RVCT |
|
130 void sort(T *array, int count) // RVCT 2.2 doesn't see recursive _static_ template function |
|
131 #else |
125 static void sort(T *array, int count) |
132 static void sort(T *array, int count) |
|
133 #endif |
126 { |
134 { |
127 // If the number of elements fall below some threshold, use insertion sort. |
135 // If the number of elements fall below some threshold, use insertion sort. |
128 const int INSERTION_SORT_LIMIT = 25; // About 25 is fastest on my computer... |
136 const int INSERTION_SORT_LIMIT = 25; // About 25 is fastest on my computer... |
129 if (count <= INSERTION_SORT_LIMIT) { |
137 if (count <= INSERTION_SORT_LIMIT) { |
130 for (int i = 1; i < count; ++i) { |
138 for (int i = 1; i < count; ++i) { |