Typedef for swap and copy function (sorting)
#include "dip_sort.h"
void (*dip_SortSwapFunction) ( data1, index1, data2, index2, copy )
A function of this type must be supplied to the sorting algorithms for data of arbitrary type. It should swap data1[index1] and data2[index2] if copy = DIP_FALSE, and copy data1[index1] to data2[index2] if copy = DIP_TRUE.
Example:
void dip_MyComplexSwap( void *data1, dip_int index1, void *data2, dip_int index2, dip_Boolean copy ) { dip_complex *cmplx1, *cmplx2, tmpValue; cmplx1 = data1; cmplx2 = data2; cmplx1 += index1; cmplx2 += index2; if ( copy == DIP_TRUE ) { cmplx2->re = cmplx1->re; cmplx2->im = cmplx1->im; } else { tmpValue.re = cmplx2->re; tmpValue.im = cmplx2->im; cmplx2->re = cmplx1->re; cmplx2->im = cmplx1->im; cmplx1->re = tmpValue.re; cmplx1->im = tmpValue.im; } return; }
Data type | Name | Description |
void * | data1 | Pointer to first data array |
dip_int | index1 | Index to element in first data array |
void * | data2 | Pointer to second data array |
dip_int | index2 | Index to element in second data array |
dip_Boolean | copy | if DIP_FALSE, swap data. if DIP_TRUE copy data from data1 to data2 |
General information about sorting
SortAnything, QuickSortAnything, SortCompareFunction
DIPlib on-line documentation | Function reference | Global function index