Woolz Image Processing Version 1.4.0
|
Specialized implementation of quick sort based on "Engineering a Sort Function" J.L. Bentley and M.D. McIlroy, Software Practice and Experience 23 (1993) 1249-1265. More...
Defines | |
#define | ALG_QSORT_SWAPCODE(TYPE, PI, PJ, N) |
#define | ALG_QSORT_SWAP(A, B) |
#define | ALG_QSORT_PVINIT(PV, PM) |
#define | ALG_QSORT_VECSWAP(A, B, N) |
Functions | |
void | AlgQSort (void *base, size_t nElm, size_t elmSz, void *cData, int(*cmpFn)(const void *, const void *, const void *)) |
A qsort implementation which allows client data to be passed to the sort function. |
Specialized implementation of quick sort based on "Engineering a Sort Function" J.L. Bentley and M.D. McIlroy, Software Practice and Experience 23 (1993) 1249-1265.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#define ALG_QSORT_SWAPCODE | ( | TYPE, | |
PI, | |||
PJ, | |||
N | |||
) |
{ \ size_t st; \ TYPE t, \ *pi = (TYPE *)(PI), \ *pj = (TYPE *)(PJ); \ \ st = sizeof(TYPE); \ do \ { \ t = *pi; \ *pi++ = *pj; \ *pj++ = t; \ } while((N -= st) > 0); \ }
#define ALG_QSORT_SWAP | ( | A, | |
B | |||
) |
if(swaptype == 0) \ { \ t = *(long *)(A); \ *(long *)(A) = *(long *)(B); \ *(long *)(B) = t; \ } \ else \ { \ AlgQSortSwapFn(A, B, es, swaptype); \ }
#define ALG_QSORT_PVINIT | ( | PV, | |
PM | |||
) |
if(swaptype != 0) \ { \ PV = a; \ ALG_QSORT_SWAP(PV, PM); \ } \ else \ { \ PV = (char *)&v; \ *(long *)PV = *(long *)PM; \ }
#define ALG_QSORT_VECSWAP | ( | A, | |
B, | |||
N | |||
) |
if(N > 0) \
{ \
AlgQSortSwapFn(A, B, N, swaptype); \
}