Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | Related Pages

RadixSort Class Reference

#include <radix.h>

List of all members.


Detailed Description

Radix sorter (original implementation by Pierre Terdiman, http://www.codecorner.com) Radix sorter that can sort signed/unsigned 32-bit integers, signed/unsigned 64-bit integers and floats. To use the sorted, pass the desired data type to the constructor and then Sort(), passing the pointer to your data (of the same type as you passed to the ctor) and number of elements in the array to sort. To access the sorted indices you use GetIndices() which will return a pointer to an index array for the sorted elements. This means the radix sorter does not modify your original data array, but gives you and index array allowing you to access the objects in sorted order.

Author:
Mattias Jansson (mattias@realityrift.com)


Public Types

enum  RADIXSORTTYPE {
  INT32 = 0x00000000, UINT32 = 0x00000001, INT64 = 0x00000002, UINT64 = 0x00000003,
  FLOAT32 = 0x00000004
}
 Supported input data types for radix sorter. More...


Public Member Functions

 RadixSort (RADIXSORTTYPE eType)
 ~RadixSort ()
RadixSortSort (const void *pInput, unsigned int uiNB)
unsigned int * GetIndices ()
unsigned int GetUsedMemory () const
unsigned int GetTotalCalls () const
unsigned int GetHits () const

Protected Member Functions

bool Resize (unsigned int uiNB)
void ResetIndices ()
bool CreateHistograms (const void *pInput, unsigned int uiNB)
RadixSortSort (const float *pfInput, unsigned int uiNB)

Protected Attributes

RADIXSORTTYPE m_eType
unsigned int m_uiCurrentSize
unsigned int m_uiPreviousSize
unsigned int * m_puiIndices
unsigned int * m_puiIndices2
unsigned int m_uiTotalCalls
unsigned int m_uiHits
unsigned int * m_puiHistogram
unsigned int * m_puiOffset


Member Enumeration Documentation

enum RADIXSORTTYPE
 

Supported input data types for radix sorter.

Enumeration values:
INT32  Signed 32bit
UINT32  Unsigned 32bit
INT64  Signed 64bit
UINT64  Unsigned 64bit
FLOAT32  Float 32bit


Constructor & Destructor Documentation

RadixSort RADIXSORTTYPE  eType  ) 
 

Parameters:
eType Data type to sort

~RadixSort  ) 
 

Free used memory


Member Function Documentation

bool Resize unsigned int  uiNB  )  [protected]
 

Resize inner lists

Parameters:
uiNB Number of indices

void ResetIndices  )  [protected]
 

Reset the inner indices

bool CreateHistograms const void *  pInput,
unsigned int  uiNB
[protected]
 

Create histograms and check for temporal coherence

Parameters:
pInput Input data to be sorted
uiNB Number of elements to be sorted
Returns:
true if already sorted, false if needs sorting

RadixSort& Sort const float *  pfInput,
unsigned int  uiNB
[protected]
 

Sort float data

Parameters:
pfInput Array of data to sort
uiNB Number of elements to sort
Returns:
self-reference

RadixSort& Sort const void *  pInput,
unsigned int  uiNB
 

Sort data based on type of sorter as passed to constructor

Parameters:
pInput Array of data to sort
uiNB Number of elements to sort
Returns:
self-reference

unsigned int* GetIndices  )  [inline]
 

Access to results, a list of indices in sorted order

Returns:
Pointer to index array with sorted indices into data array sent to sort method

unsigned int GetUsedMemory  )  const
 

Returns:
Memory used by this sort object

unsigned int GetTotalCalls  )  const [inline]
 

Returns:
Total number of calls to the radix sorter

unsigned int GetHits  )  const [inline]
 

Returns:
Number of premature exits due to temporal coherence


Member Data Documentation

RADIXSORTTYPE m_eType [protected]
 

Data type

unsigned int m_uiCurrentSize [protected]
 

Current size of the indices list

unsigned int m_uiPreviousSize [protected]
 

Size involved in previous call

unsigned int* m_puiIndices [protected]
 

Lists swapped each pass, first list

unsigned int* m_puiIndices2 [protected]
 

Lists swapped each pass, second list

unsigned int m_uiTotalCalls [protected]
 

Statistics, total sort calls

unsigned int m_uiHits [protected]
 

Statistics, premature exits due to temporal coherence

unsigned int* m_puiHistogram [protected]
 

Histogram array

unsigned int* m_puiOffset [protected]
 

Offset array


The documentation for this class was generated from the following file:
Generated on Wed Jan 21 14:21:14 2004 for NeoEngine by doxygen 1.3.5