cgul_radix_sort_cxx Class Reference

C++ bindings for cgul_radix_sort More...

#include <cgul_radix_sort_cxx.h>

Collaboration diagram for cgul_radix_sort_cxx:
Collaboration graph

Public Types

typedef cgul_radix_sort__enumerate_t enumerate_t
 

Static Public Member Functions

static void cgul_radix_sort (void *v, size_t v_count, size_t element_size, int ascending_order, enumerate_t ef, int are_enumerations_signed)
 
static void cgul_radix_sort_pointers (void **v, size_t v_count, int ascending_order, enumerate_t ef, int are_enumerations_signed)
 
static void cgul_radix_sort_schar (signed char *v, size_t v_count, int ascending_order)
 
static void cgul_radix_sort_uchar (unsigned char *v, size_t v_count, int ascending_order)
 
static void cgul_radix_sort_short (short int *v, size_t v_count, int ascending_order)
 
static void cgul_radix_sort_ushort (unsigned short int *v, size_t v_count, int ascending_order)
 
static void cgul_radix_sort_int (int *v, size_t v_count, int ascending_order)
 
static void cgul_radix_sort_uint (unsigned int *v, size_t v_count, int ascending_order)
 
static void cgul_radix_sort_long (long int *v, size_t v_count, int ascending_order)
 
static void cgul_radix_sort_ulong (unsigned long int *v, size_t v_count, int ascending_order)
 
static void cgul_radix_sort_int8 (cgul_int8_t *v, size_t v_count, int ascending_order)
 
static void cgul_radix_sort_uint8 (cgul_uint8_t *v, size_t v_count, int ascending_order)
 
static void cgul_radix_sort_int16 (cgul_int16_t *v, size_t v_count, int ascending_order)
 
static void cgul_radix_sort_uint16 (cgul_uint16_t *v, size_t v_count, int ascending_order)
 
static void cgul_radix_sort_int32 (cgul_int32_t *v, size_t v_count, int ascending_order)
 
static void cgul_radix_sort_uint32 (cgul_uint32_t *v, size_t v_count, int ascending_order)
 

Detailed Description

This class provides the C++ bindings for cgul_radix_sort. The main purpose of this class is to convert the C-style function calls and exception handling into C++-style function calls and exception handling.

Member Typedef Documentation

§ enumerate_t

This typedef is the interface the client must define in order for cgul_radix_sort() or cgul_radix_sort_pointers() to sort an array. This function will be called repeatedly during the sorting process, and it should consistently return the same unsigned long value that is associated with the element element from the array being sorted. The elements from the array will then be sorted in ascending order of the enumerations.

If a signed enumeration is more natural for the array being sorted, just have your enumeration function cast the signed enumeration to an unsigned long and use the are_enumerations_signed parameter that is provided for all functions that accept an enumeration function. Alternatively, your enumeration function could just shift the signed values into the unsigned range and return only unsigned values. If the shifted sort order is the same as the original sort order, the end result will be the same.

Parameters
[in]elementelement from the array being sorted
Returns
enumeration for element

Member Function Documentation

§ cgul_radix_sort()

static void cgul_radix_sort_cxx::cgul_radix_sort ( void *  v,
size_t  v_count,
size_t  element_size,
int  ascending_order,
enumerate_t  ef,
int  are_enumerations_signed 
)
inlinestatic

Perform an in-place radix sort on the array v which holds v_count instances of values having size element_size (in bytes). To sort the array of values, the client must supply the enumeration function ef that maps each value to an integer. This function sorts the values in ascending order of their enumerations if ascending_order is true or in descending order otherwise. If are_enumerations_signed is true, the enumeration returned by ef will be treated is a signed type and sorted accordingly; otherwise, it will be treated as an unsigned type. Because of all the callbacks, this function is about 5x slower than the functions (below) that are optimized for sorting arrays of integers. (This function uses cgul_radix_sort_pointers(), but it can be faster than cgul_radix_sort_pointers() because calling this function means all the values are located in contigous memory which improves locality of reference.) This functions internally allocates (and releases) an extra array large enough to hold a copy of v. If an error occurs, an exception is thrown.

Parameters
[in]varray of elements to sort
[in]v_countnumber of elements in v
[in]element_sizesize of each element in v (in bytes)
[in]ascending_orderwhether to sort in ascending order
[in]efenumeration function
[in]are_enumerations_signedwhether the enumerations are signed

§ cgul_radix_sort_pointers()

static void cgul_radix_sort_cxx::cgul_radix_sort_pointers ( void **  v,
size_t  v_count,
int  ascending_order,
enumerate_t  ef,
int  are_enumerations_signed 
)
inlinestatic

Perform an in-place radix sort on the array v which holds v_count instances of pointers to values. To sort the array of pointers, the client must supply the enumeration function ef that maps each pointer to an integer. This function sorts the pointers in ascending order of their enumerations if ascending_order is true or in descending order otherwise. If are_enumerations_signed is true, the enumeration returned by ef will be treated is a signed type and sorted accordingly; otherwise, it will be treated as an unsigned type. Because of all the callbacks, this function is about 10x slower than the functions (below) that are optimized for sorting arrays of integers. This functions internally allocates (and releases) an extra array large enough to hold a copy of v. If an error occurs, an exception is thrown.

Parameters
[in]varray of elements to sort
[in]v_countnumber of elements in v
[in]ascending_orderwhether to sort in ascending order
[in]efenumeration function
[in]are_enumerations_signedwhether the enumerations are signed

§ cgul_radix_sort_schar()

static void cgul_radix_sort_cxx::cgul_radix_sort_schar ( signed char *  v,
size_t  v_count,
int  ascending_order 
)
inlinestatic

Perform an in-place radix sort on the array v which holds v_count instances of signed char values. On return, v will be in ascending order if ascending_order is true or in descending order otherwise. This functions internally allocates (and releases) an extra array large enough to hold a copy of v. This function assumes the computer represents negative values using two's complement (which should be true for the vast majority of computers). If an error occurs, an exception is thrown.

If another sort order is desired, use cgul_radix_sort() or cgul_radix_sort_pointers(), but they are much slower than this function.

Parameters
[in]varray of elements to sort
[in]v_countnumber of elements in v
[in]ascending_orderwhether to sort in ascending order

§ cgul_radix_sort_uchar()

static void cgul_radix_sort_cxx::cgul_radix_sort_uchar ( unsigned char *  v,
size_t  v_count,
int  ascending_order 
)
inlinestatic

Perform an in-place radix sort on the array v which holds v_count instances of unsigned char values. On return, v will be in ascending order if ascending_order is true or in descending order otherwise. This functions internally allocates (and releases) an extra array large enough to hold a copy of v. If an error occurs, an exception is thrown.

If another sort order is desired, use cgul_radix_sort() or cgul_radix_sort_pointers(), but they are much slower than this function.

Parameters
[in]varray of elements to sort
[in]v_countnumber of elements in v
[in]ascending_orderwhether to sort in ascending order

§ cgul_radix_sort_short()

static void cgul_radix_sort_cxx::cgul_radix_sort_short ( short int *  v,
size_t  v_count,
int  ascending_order 
)
inlinestatic

Perform an in-place radix sort on the array v which holds v_count instances of short values. On return, v will be in ascending order if ascending_order is true or in descending order otherwise. This functions internally allocates (and releases) an extra array large enough to hold a copy of v. This function assumes the computer represents negative values using two's complement (which should be true for the vast majority of computers). If an error occurs, an exception is thrown.

If another sort order is desired, use cgul_radix_sort() or cgul_radix_sort_pointers(), but they are much slower than this function.

Parameters
[in]varray of elements to sort
[in]v_countnumber of elements in v
[in]ascending_orderwhether to sort in ascending order

§ cgul_radix_sort_ushort()

static void cgul_radix_sort_cxx::cgul_radix_sort_ushort ( unsigned short int *  v,
size_t  v_count,
int  ascending_order 
)
inlinestatic

Perform an in-place radix sort on the array v which holds v_count instances of unsigned short values. On return, v will be in ascending order if ascending_order is true or in descending order otherwise. This functions internally allocates (and releases) an extra array large enough to hold a copy of v. If an error occurs, an exception is thrown.

If another sort order is desired, use cgul_radix_sort() or cgul_radix_sort_pointers(), but they are much slower than this function.

Parameters
[in]varray of elements to sort
[in]v_countnumber of elements in v
[in]ascending_orderwhether to sort in ascending order

§ cgul_radix_sort_int()

static void cgul_radix_sort_cxx::cgul_radix_sort_int ( int *  v,
size_t  v_count,
int  ascending_order 
)
inlinestatic

Perform an in-place radix sort on the array v which holds v_count instances of int values. On return, v will be in ascending order if ascending_order is true or in descending order otherwise. This functions internally allocates (and releases) an extra array large enough to hold a copy of v. This function assumes the computer represents negative values using two's complement (which should be true for the vast majority of computers). If an error occurs, an exception is thrown.

If another sort order is desired, use cgul_radix_sort() or cgul_radix_sort_pointers(), but they are much slower than this function.

Parameters
[in]varray of elements to sort
[in]v_countnumber of elements in v
[in]ascending_orderwhether to sort in ascending order

§ cgul_radix_sort_uint()

static void cgul_radix_sort_cxx::cgul_radix_sort_uint ( unsigned int *  v,
size_t  v_count,
int  ascending_order 
)
inlinestatic

Perform an in-place radix sort on the array v which holds v_count instances of unsigned int values. On return, v will be in ascending order if ascending_order is true or in descending order otherwise. This functions internally allocates (and releases) an extra array large enough to hold a copy of v. If an error occurs, an exception is thrown.

If another sort order is desired, use cgul_radix_sort() or cgul_radix_sort_pointers(), but they are much slower than this function.

Parameters
[in]varray of elements to sort
[in]v_countnumber of elements in v
[in]ascending_orderwhether to sort in ascending order

§ cgul_radix_sort_long()

static void cgul_radix_sort_cxx::cgul_radix_sort_long ( long int *  v,
size_t  v_count,
int  ascending_order 
)
inlinestatic

Perform an in-place radix sort on the array v which holds v_count instances of long values. On return, v will be in ascending order if ascending_order is true or in descending order otherwise. This functions internally allocates (and releases) an extra array large enough to hold a copy of v. This function assumes the computer represents negative values using two's complement (which should be true for the vast majority of computers). If an error occurs, an exception is thrown.

If another sort order is desired, use cgul_radix_sort() or cgul_radix_sort_pointers(), but they are much slower than this function.

Parameters
[in]varray of elements to sort
[in]v_countnumber of elements in v
[in]ascending_orderwhether to sort in ascending order

§ cgul_radix_sort_ulong()

static void cgul_radix_sort_cxx::cgul_radix_sort_ulong ( unsigned long int *  v,
size_t  v_count,
int  ascending_order 
)
inlinestatic

Perform an in-place radix sort on the array v which holds v_count instances of unsigned long values. On return, v will be in ascending order if ascending_order is true or in descending order otherwise. This functions internally allocates (and releases) an extra array large enough to hold a copy of v. If an error occurs, an exception is thrown.

If another sort order is desired, use cgul_radix_sort() or cgul_radix_sort_pointers(), but they are much slower than this function.

Parameters
[in]varray of elements to sort
[in]v_countnumber of elements in v
[in]ascending_orderwhether to sort in ascending order

§ cgul_radix_sort_int8()

static void cgul_radix_sort_cxx::cgul_radix_sort_int8 ( cgul_int8_t v,
size_t  v_count,
int  ascending_order 
)
inlinestatic

Perform an in-place radix sort on the array v which holds v_count instances of cgul_int8_t values. On return, v will be in ascending order if ascending_order is true or in descending order otherwise. This functions internally allocates (and releases) an extra array large enough to hold a copy of v. This function assumes the computer represents negative values using two's complement (which should be true for the vast majority of computers). If an error occurs, an exception is thrown.

If another sort order is desired, use cgul_radix_sort() or cgul_radix_sort_pointers(), but they are much slower than this function.

Parameters
[in]varray of elements to sort
[in]v_countnumber of elements in v
[in]ascending_orderwhether to sort in ascending order

§ cgul_radix_sort_uint8()

static void cgul_radix_sort_cxx::cgul_radix_sort_uint8 ( cgul_uint8_t v,
size_t  v_count,
int  ascending_order 
)
inlinestatic

Perform an in-place radix sort on the array v which holds v_count instances of cgul_uint8_t values. On return, v will be in ascending order if ascending_order is true or in descending order otherwise. This functions internally allocates (and releases) an extra array large enough to hold a copy of v. If an error occurs, an exception is thrown.

If another sort order is desired, use cgul_radix_sort() or cgul_radix_sort_pointers(), but they are much slower than this function.

Parameters
[in]varray of elements to sort
[in]v_countnumber of elements in v
[in]ascending_orderwhether to sort in ascending order

§ cgul_radix_sort_int16()

static void cgul_radix_sort_cxx::cgul_radix_sort_int16 ( cgul_int16_t v,
size_t  v_count,
int  ascending_order 
)
inlinestatic

Perform an in-place radix sort on the array v which holds v_count instances of cgul_int16_t values. On return, v will be in ascending order if ascending_order is true or in descending order otherwise. This functions internally allocates (and releases) an extra array large enough to hold a copy of v. This function assumes the computer represents negative values using two's complement (which should be true for the vast majority of computers). If an error occurs, an exception is thrown.

If another sort order is desired, use cgul_radix_sort() or cgul_radix_sort_pointers(), but they are much slower than this function.

Parameters
[in]varray of elements to sort
[in]v_countnumber of elements in v
[in]ascending_orderwhether to sort in ascending order

§ cgul_radix_sort_uint16()

static void cgul_radix_sort_cxx::cgul_radix_sort_uint16 ( cgul_uint16_t v,
size_t  v_count,
int  ascending_order 
)
inlinestatic

Perform an in-place radix sort on the array v which holds v_count instances of cgul_uint16_t values. On return, v will be in ascending order if ascending_order is true or in descending order otherwise. This functions internally allocates (and releases) an extra array large enough to hold a copy of v. If an error occurs, an exception is thrown.

If another sort order is desired, use cgul_radix_sort() or cgul_radix_sort_pointers(), but they are much slower than this function.

Parameters
[in]varray of elements to sort
[in]v_countnumber of elements in v
[in]ascending_orderwhether to sort in ascending order

§ cgul_radix_sort_int32()

static void cgul_radix_sort_cxx::cgul_radix_sort_int32 ( cgul_int32_t *  v,
size_t  v_count,
int  ascending_order 
)
inlinestatic

Perform an in-place radix sort on the array v which holds v_count instances of cgul_int32_t values. On return, v will be in ascending order if ascending_order is true or in descending order otherwise. This functions internally allocates (and releases) an extra array large enough to hold a copy of v. This function assumes the computer represents negative values using two's complement (which should be true for the vast majority of computers). If an error occurs, an exception is thrown.

If another sort order is desired, use cgul_radix_sort() or cgul_radix_sort_pointers(), but they are much slower than this function.

Parameters
[in]varray of elements to sort
[in]v_countnumber of elements in v
[in]ascending_orderwhether to sort in ascending order

§ cgul_radix_sort_uint32()

static void cgul_radix_sort_cxx::cgul_radix_sort_uint32 ( cgul_uint32_t *  v,
size_t  v_count,
int  ascending_order 
)
inlinestatic

Perform an in-place radix sort on the array v which holds v_count instances of cgul_uint32_t values. On return, v will be in ascending order if ascending_order is true or in descending order otherwise. This functions internally allocates (and releases) an extra array large enough to hold a copy of v. If an error occurs, an exception is thrown.

If another sort order is desired, use cgul_radix_sort() or cgul_radix_sort_pointers(), but they are much slower than this function.

Parameters
[in]varray of elements to sort
[in]v_countnumber of elements in v
[in]ascending_orderwhether to sort in ascending order

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