- while(it < rit)\r
- if(*it <= *start)\r
- ++it;\r
- else if(*rit > *start)\r
- --rit;\r
- else\r
- *it ^= (*it ^= *rit, *rit ^= *it);\r
+typedef struct bucket {\r
+ uint32_t *head;\r
+ uint32_t *bp;\r
+} bucket_t;\r
+\r
+typedef bucket_t bucket_array_t[2][0x100];\r
+\r
+typedef struct bucket_info {\r
+ struct {\r
+ uint32_t *head, *tail;\r
+ } bucket_info[2][0x100];\r
+ uint32_t numbuckets;\r
+ } bucket_info_t;\r
+\r
+\r
+static void bucket_sort_intersect(uint32_t* const estart, uint32_t* const estop,\r
+ uint32_t* const ostart, uint32_t* const ostop,\r
+ bucket_info_t *bucket_info, bucket_array_t bucket)\r
+{\r
+ uint32_t *p1, *p2;\r
+ uint32_t *start[2];\r
+ uint32_t *stop[2];\r
+\r
+ start[0] = estart;\r
+ stop[0] = estop;\r
+ start[1] = ostart;\r
+ stop[1] = ostop;\r
+\r
+ // init buckets to be empty\r
+ for (uint32_t i = 0; i < 2; i++) {\r
+ for (uint32_t j = 0x00; j <= 0xff; j++) {\r
+ bucket[i][j].bp = bucket[i][j].head;\r
+ }\r
+ }\r
+\r
+ // sort the lists into the buckets based on the MSB (contribution bits)\r
+ for (uint32_t i = 0; i < 2; i++) {\r
+ for (p1 = start[i]; p1 <= stop[i]; p1++) {\r
+ uint32_t bucket_index = (*p1 & 0xff000000) >> 24;\r
+ *(bucket[i][bucket_index].bp++) = *p1;\r
+ }\r
+ }\r