# Home    # nevrax.com   
Nevrax
Nevrax.org
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
Docs
 
Documentation  
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  

NL3D::CRadixSort Class Template Reference

A class which sort elements T with radix sort algorithm. More...

#include <radix_sort.h>

List of all members.

Public Methods

 CRadixSort (uint keyDepth=32, uint digitDepth=8)
 Constructor. More...

T * sort (T *array0, T *array1, uint size)
 Sort an array of T, in (keyDepth/digitSize)*O(size). More...

T * reverse_sort (T *array0, T *array1, uint size)
 same as sort(), but elements are reordered in decreasing order. More...


Private Methods

T * doSort (T *arraySrc, T *arrayDst, uint size, bool increasingOrder)
 radix sort algorithm. More...


Private Attributes

uint _KeyDepth
uint _DigitDepth
uint _DigitSize
std::vector< CSortDigit_SortDigits


Detailed Description

template<class T>
class NL3D::CRadixSort< T >

A class which sort elements T with radix sort algorithm.

T must follow the following interface:

  • uint32 getRadixKey() const;
  • have a correct operator=()
getRadixKey() return the unsigned key for this element.

Author:
Lionel Berenguier , Nevrax France
Date:
2001

Definition at line 49 of file radix_sort.h.


Constructor & Destructor Documentation

template<class T>
NL3D::CRadixSort< T >::CRadixSort uint    keyDepth = 32,
uint    digitDepth = 8
[inline]
 

Constructor.

Parameters:
keyDepth  default is 32 bits, but if as example you're sure that you just use 14 bits, you can set keyDepth=14. Clamped to 1,32.
digitDepth  default is 8 bits. The sort will do ceil(keyDepth/digitDepth) pass in Sort. But be aware that a CRadixSort object has a size of (1<<digitDepth) * 8 bytes. (2K for digitDepth=8). Be aware too that values>8 is not a really good idea because of cache, and random access... And this REALLY impact (eg: from 1 to 100 if you choose 16 instead than 8...) Clamped to 1,min(16, keyDepth).

Definition at line 62 of file radix_sort.h.

References _DigitDepth, _DigitSize, _KeyDepth, _SortDigits, NLMISC::clamp, and min.


Member Function Documentation

template<class T>
T* NL3D::CRadixSort< T >::doSort T *    arraySrc,
T *    arrayDst,
uint    size,
bool    increasingOrder
[inline, private]
 

radix sort algorithm.

Definition at line 113 of file radix_sort.h.

References _DigitDepth, _DigitSize, _KeyDepth, and _SortDigits.

Referenced by reverse_sort, and sort.

template<class T>
T* NL3D::CRadixSort< T >::reverse_sort T *    array0,
T *    array1,
uint    size
[inline]
 

same as sort(), but elements are reordered in decreasing order.

See also:
sort()

Definition at line 90 of file radix_sort.h.

References doSort.

template<class T>
T* NL3D::CRadixSort< T >::sort T *    array0,
T *    array1,
uint    size
[inline]
 

Sort an array of T, in (keyDepth/digitSize)*O(size).

Elements are reordered in increasing order.

Parameters:
array0  ptr on elements to be sorted.
array1  an array of T which must be allocated with same size.
size  the number of elements.
Returns:
the array which have sorted elements. Actually return array0 if ceil(keyDepth/digitDepth) is pair, else return array1. The other array has elements in undefined order.

Definition at line 84 of file radix_sort.h.

References doSort.


Member Data Documentation

template<class T>
uint NL3D::CRadixSort::_DigitDepth [private]
 

Definition at line 106 of file radix_sort.h.

Referenced by CRadixSort, and doSort.

template<class T>
uint NL3D::CRadixSort::_DigitSize [private]
 

Definition at line 107 of file radix_sort.h.

Referenced by CRadixSort, and doSort.

template<class T>
uint NL3D::CRadixSort::_KeyDepth [private]
 

Definition at line 105 of file radix_sort.h.

Referenced by CRadixSort, and doSort.

template<class T>
std::vector<CSortDigit> NL3D::CRadixSort::_SortDigits [private]
 

Definition at line 109 of file radix_sort.h.

Referenced by CRadixSort, and doSort.


The documentation for this class was generated from the following file: