1 #ifndef GIM_RADIXSORT_H_INCLUDED     2 #define GIM_RADIXSORT_H_INCLUDED    45         template<
class T,
class Z>
    48                 return ( a<b?-1:(a>b?1:0));
   109         m_key = rtoken.
m_key;
   115                 return (m_key < other.
m_key);
   120                 return (m_key > other.
m_key);
   139 #define D11_0(x)        (x & 0x7FF)   140 #define D11_1(x)        (x >> 11 & 0x7FF)   141 #define D11_2(x)        (x >> 22 )   154         for (i = 0; i < kHist * 3; ++i)
   160         for (i = 0; i < element_count; ++i)
   168                 GUINT sum0 = 0, sum1 = 0, sum2 = 0;
   170                 for (i = 0; i < 
kHist; ++i)
   183         for (i = 0; i < element_count; ++i)
   191         for (i = 0; i < element_count; ++i)
   193         fi = sorted[i].
m_key;
   199         for (i = 0; i < element_count; ++i)
   219 template<
typename T, 
class GETKEY_CLASS>
   223                         GUINT element_count,GETKEY_CLASS uintkey_macro)
   226     for (
GUINT _i=0;_i<element_count;++_i)
   228         _unsorted[_i].
m_key = uintkey_macro(array[_i]);
   244 template<
typename T, 
class GETKEY_CLASS, 
class COPY_CLASS>
   246         T * array, 
GUINT element_count,
   247         GETKEY_CLASS get_uintkey_macro, COPY_CLASS copy_elements_macro)
   251     T * _original_array = (T *) 
gim_alloc(
sizeof(T)*element_count);
   253     for (
GUINT _i=0;_i<element_count;++_i)
   255         copy_elements_macro(array[_i],_original_array[_sorted[_i].m_value]);
   272 template<
class T, 
typename KEYCLASS, 
typename COMP_CLASS>
   274                 const T* _array, 
GUINT _start_i,
   276                 const KEYCLASS & _search_key,
   277                 COMP_CLASS _comp_macro)
   286                 _comp_result = _comp_macro(_array[_k], _search_key);
   287                 if (_comp_result == 0)
   292                 else if (_comp_result < 0)
   319         const T*_array,
GUINT _start_i,
   320         GUINT _end_i,
const T & _search_key,
   321         GUINT & _result_index)
   329                 if(_array[_k]==_search_key)
   334                 else if (_array[_k]<_search_key)
   350 template <
typename T, 
typename COMP_CLASS>
   356         T temp = pArr[k - 1];
   362                 if ((child < (
int)n) && CompareFunc(pArr[child - 1] , pArr[child])<0)
   367                 if (CompareFunc(temp , pArr[child - 1])<0)
   370                         pArr[k - 1] = pArr[child - 1];
   382 template <
typename T, 
typename COMP_CLASS>
   387         GUINT n = element_count;
   388         for (k = n/2; k > 0; k--)
   406 #endif // GIM_RADIXSORT_H_INCLUDED void gim_simd_memcpy(void *dst, const void *src, size_t copysize)
Prototype for copying elements. 
void gim_down_heap(T *pArr, GUINT k, GUINT n, COMP_CLASS CompareFunc)
heap sort from http://www.csse.monash.edu.au/~lloyd/tildeAlgDS/Sort/Heap/ 
bool gim_binary_search(const T *_array, GUINT _start_i, GUINT _end_i, const T &_search_key, GUINT &_result_index)
Failsafe Iterative binary search,Template version. 
void operator()(T &a, T &b)
Prototype for comparators. 
void gim_heap_sort(T *pArr, GUINT element_count, COMP_CLASS CompareFunc)
int operator()(const GIM_RSORT_TOKEN &a, const GIM_RSORT_TOKEN &b)
void operator()(T &a, T &b)
GIM_RSORT_TOKEN(const GIM_RSORT_TOKEN &rtoken)
void gim_radix_sort_rtokens(GIM_RSORT_TOKEN *array, GIM_RSORT_TOKEN *sorted, GUINT element_count)
Radix sort for unsigned integer keys. 
Prototype for getting the integer representation of an object. 
bool gim_binary_search_ex(const T *_array, GUINT _start_i, GUINT _end_i, GUINT &_result_index, const KEYCLASS &_search_key, COMP_CLASS _comp_macro)
Failsafe Iterative binary search,. 
Prototype for comparators. 
void gim_swap_elements(T *_array, size_t _i, size_t _j)
void gim_radix_sort(T *array, GUINT element_count, GETKEY_CLASS get_uintkey_macro, COPY_CLASS copy_elements_macro)
Sorts array in place. For generic use. 
void * gim_alloc(size_t size)
Standar Memory functions. 
GUINT operator()(const T &a)
int operator()(const T &a, const Z &b)
void gim_radix_sort_array_tokens(T *array, GIM_RSORT_TOKEN *sorted_tokens, GUINT element_count, GETKEY_CLASS uintkey_macro)
Get the sorted tokens from an array. For generic use. Tokens are IRR_RSORT_TOKEN. ...
Prototype for copying elements.