mi32/sort.h

Go to the documentation of this file.
00001 /**
00002  * \file sort.h <mi32/sort.h>
00003  * \brief Sorting functions
00004  *
00005  * \if NODOC
00006  * $Id: sort.h_v 1.1 2005/07/14 17:29:42 mju Exp $
00007  *
00008  * $Log: sort.h_v $
00009  * Revision 1.1  2005/07/14 17:29:42  mju
00010  * Initial revision
00011  *
00012  * \endif
00013 **/
00014 
00015 #ifndef  INC_MI32_SORT_H
00016 #define  INC_MI32_SORT_H
00017 
00018 #ifndef  INC_MI32_STDDEFNS_H
00019 #include <mi32/stddefns.h>
00020 #endif
00021 
00022 #ifdef MISYSTEMDLL
00023    #define LIBEXPORT MI_DLLEXPORT
00024 #else
00025    #define LIBEXPORT MI_DLLIMPORT
00026 #endif
00027 
00028 
00029 #if defined(MAC_OSX) && !defined(GENERATING_DOXYGEN_OUTPUT)
00030 // Mac OSX standard library defines their own heapsort which takes a
00031 // different compare function.  This makes sure we link to ours, not
00032 // theirs.
00033 #define heapsort heapsort_MicroImages
00034 #endif
00035 
00036 #if defined(__cplusplus)
00037 extern "C" {
00038 #endif
00039 
00040 //!\addtogroup sort Sorting Functions
00041 //!@{
00042 
00043 //! Memory based heapsort.
00044 //!
00045 //! Sorts an array in memory.  Assumes it can use memcpy() to swap items.
00046 LIBEXPORT void heapsort (
00047    void* array,                        //!< Array to sort 
00048    INT32 n,                            //!< Number of elements in array
00049    INT32 size,                         //!< sizeof() each element
00050    int (*compare)(void*a, void*b, void*hookdata),  //! Compare function. Return 1 if *a <= *b.
00051    void* hookdata                      //!< Passed as 3rd parameter to compare function
00052    );
00053 
00054 //! Generic Heapsort.
00055 LIBEXPORT int HeapSortGen (
00056    INT32 n,                            //!< Number of items to sort
00057    int (*compare)(INT32 a, INT32 b, void* hookdata),  //! Return 1 if item a <= item b
00058    int (*swap)(INT32 a, INT32 b, void* hookdata),     //! Swap two items
00059    void* hookdata                      //!< Passed as 3rd parameter to compare and swap functions
00060    );
00061 //!@}
00062 
00063 #if defined(__cplusplus)
00064 }
00065 #endif
00066 
00067 
00068 #undef   LIBEXPORT
00069 
00070 #endif   // INC_MI32_SORT_H

Generated on Thu Apr 26 04:04:50 2007 for TNTsdk by  doxygen 1.5.2