| Bullet Collision Detection & Physics Library
    | 
 
 
 
Go to the documentation of this file.    1 #ifndef GIM_RADIXSORT_H_INCLUDED 
    2 #define GIM_RADIXSORT_H_INCLUDED 
   44         template <
class T, 
class Z>
 
   47                 return (a < b ? -1 : (a > b ? 1 : 0));
 
  132 #define D11_0(x) (x & 0x7FF) 
  133 #define D11_1(x) (x >> 11 & 0x7FF) 
  134 #define D11_2(x) (x >> 22) 
  145         for (i = 0; i < 
kHist * 3; ++i)
 
  151         for (i = 0; i < element_count; ++i)
 
  159                 GUINT sum0 = 0, sum1 = 0, sum2 = 0;
 
  161                 for (i = 0; i < 
kHist; ++i)
 
  174         for (i = 0; i < element_count; ++i)
 
  182         for (i = 0; i < element_count; ++i)
 
  184                 fi = sorted[i].
m_key;
 
  190         for (i = 0; i < element_count; ++i)
 
  207 template <
typename T, 
class GETKEY_CLASS>
 
  211         GUINT element_count, GETKEY_CLASS uintkey_macro)
 
  214         for (
GUINT _i = 0; _i < element_count; ++_i)
 
  216                 _unsorted[_i].
m_key = uintkey_macro(array[_i]);
 
  232 template <
typename T, 
class GETKEY_CLASS, 
class COPY_CLASS>
 
  234         T* array, 
GUINT element_count,
 
  235         GETKEY_CLASS get_uintkey_macro, COPY_CLASS copy_elements_macro)
 
  239         T* _original_array = (T*)
gim_alloc(
sizeof(T) * element_count);
 
  241         for (
GUINT _i = 0; _i < element_count; ++_i)
 
  243                 copy_elements_macro(array[_i], _original_array[_sorted[_i].m_value]);
 
  260 template <
class T, 
typename KEYCLASS, 
typename COMP_CLASS>
 
  262         const T* _array, 
GUINT _start_i,
 
  264         const KEYCLASS& _search_key,
 
  265         COMP_CLASS _comp_macro)
 
  270         GUINT _j = _end_i + 1;
 
  273                 _k = (_j + _i - 1) / 2;
 
  274                 _comp_result = _comp_macro(_array[_k], _search_key);
 
  275                 if (_comp_result == 0)
 
  280                 else if (_comp_result < 0)
 
  305         const T* _array, 
GUINT _start_i,
 
  306         GUINT _end_i, 
const T& _search_key,
 
  307         GUINT& _result_index)
 
  310         GUINT _j = _end_i + 1;
 
  314                 _k = (_j + _i - 1) / 2;
 
  315                 if (_array[_k] == _search_key)
 
  320                 else if (_array[_k] < _search_key)
 
  334 template <
typename T, 
typename COMP_CLASS>
 
  340         T temp = pArr[k - 1];
 
  346                 if ((child < (
int)n) && CompareFunc(pArr[child - 1], pArr[child]) < 0)
 
  351                 if (CompareFunc(temp, pArr[child - 1]) < 0)
 
  354                         pArr[k - 1] = pArr[child - 1];
 
  365 template <
typename T, 
typename COMP_CLASS>
 
  370         GUINT n = element_count;
 
  371         for (k = n / 2; k > 0; k--)
 
  386 #endif  // GIM_RADIXSORT_H_INCLUDED 
 
int operator()(const T &a, const T &b)
GIM_RSORT_TOKEN(const GIM_RSORT_TOKEN &rtoken)
int operator()(const T &a, const Z &b)
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.
Prototype for comparators.
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 comparators.
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.
int operator()(const GIM_RSORT_TOKEN &a, const GIM_RSORT_TOKEN &b)
bool operator>(const GIM_RSORT_TOKEN &other) const
void operator()(T &a, T &b)
bool operator<(const GIM_RSORT_TOKEN &other) const
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,.
void gim_radix_sort_rtokens(GIM_RSORT_TOKEN *array, GIM_RSORT_TOKEN *sorted, GUINT element_count)
Radix sort for unsigned integer keys.
void gim_swap_elements(T *_array, size_t _i, size_t _j)
void operator()(T &a, T &b)
void gim_simd_memcpy(void *dst, const void *src, size_t copysize)
Prototype for copying elements.
void * gim_alloc(size_t size)
Standar Memory functions.
Prototype for copying elements.
GUINT operator()(const T &a)
void gim_heap_sort(T *pArr, GUINT element_count, COMP_CLASS CompareFunc)
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/