Woolz Image Processing  Version 1.8.3
AlgQSort.c File Reference

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...

Macros

#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. More...
 

Detailed Description

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.

Author
Bill Hill
Date
August 2004
Version
Id
df7f583b2d829a1c6dcba08ddd160bcd783eec67
Address: MRC Human Genetics Unit, MRC Institute of Genetics and Molecular Medicine, University of Edinburgh, Western General Hospital, Edinburgh, EH4 2XU, UK.
Copyright (C), [2012], The University Court of the University of Edinburgh, Old College, Edinburgh, UK.

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.

Macro Definition Documentation

◆ ALG_QSORT_SWAPCODE

#define ALG_QSORT_SWAPCODE (   TYPE,
  PI,
  PJ,
 
)
Value:
{ \
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); \
}

◆ ALG_QSORT_SWAP

#define ALG_QSORT_SWAP (   A,
 
)
Value:
if(swaptype == 0) \
{ \
t = *(long *)(A); \
*(long *)(A) = *(long *)(B); \
*(long *)(B) = t; \
} \
else \
{ \
AlgQSortSwapFn(A, B, es, swaptype); \
}

◆ ALG_QSORT_PVINIT

#define ALG_QSORT_PVINIT (   PV,
  PM 
)
Value:
if(swaptype != 0) \
{ \
PV = a; \
ALG_QSORT_SWAP(PV, PM); \
} \
else \
{ \
PV = (char *)&v; \
*(long *)PV = *(long *)PM; \
}

◆ ALG_QSORT_VECSWAP

#define ALG_QSORT_VECSWAP (   A,
  B,
 
)
Value:
if(N > 0) \
{ \
AlgQSortSwapFn(A, B, N, swaptype); \
}