00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include <config.h>
00024
00025 #include <drizzled/internal/my_sys.h>
00026 #include <drizzled/internal/m_string.h>
00027
00028 namespace drizzled
00029 {
00030 namespace internal
00031 {
00032
00033
00034
00035 void radixsort_for_str_ptr(unsigned char **base, uint32_t number_of_elements, size_t size_of_element, unsigned char **buffer)
00036 {
00037 unsigned char **end,**ptr,**buffer_ptr;
00038 uint32_t *count_ptr,*count_end,count[256];
00039 int pass;
00040
00041 end=base+number_of_elements; count_end=count+256;
00042 for (pass=(int) size_of_element-1 ; pass >= 0 ; pass--)
00043 {
00044 memset(count, 0, sizeof(uint32_t)*256);
00045 for (ptr= base ; ptr < end ; ptr++)
00046 count[ptr[0][pass]]++;
00047 if (count[0] == number_of_elements)
00048 goto next;
00049 for (count_ptr=count+1 ; count_ptr < count_end ; count_ptr++)
00050 {
00051 if (*count_ptr == number_of_elements)
00052 goto next;
00053 (*count_ptr)+= *(count_ptr-1);
00054 }
00055 for (ptr= end ; ptr-- != base ;)
00056 buffer[--count[ptr[0][pass]]]= *ptr;
00057 for (ptr=base, buffer_ptr=buffer ; ptr < end ;)
00058 (*ptr++) = *buffer_ptr++;
00059 next:;
00060 }
00061 }
00062
00063 }
00064 }