Libical API Documentation 4.0
Loading...
Searching...
No Matches
qsort_gen.h File Reference

An implementation of qsort that is more flexible than the version provided with stdlib. More...

Go to the source code of this file.

Functions

void qsort_gen (void *list, size_t nitems, int(*compar)(const void *, size_t, size_t), void(*swapr)(void *, size_t, size_t))
 Sort an arbitrary list of items using the qsort algorithm. interpreted by this function but passed to the compar and swapr functions.
 
void qsort_gen_memswap (void *m1, void *m2, size_t size)
 Swaps two arbitrary blocks of memory.
 

Detailed Description

An implementation of qsort that is more flexible than the version provided with stdlib.

In contrast to the qsort provided with stdlib, this version doesn't assume that the data to be sorted is stored in a contiguous block of memory.

Function Documentation

◆ qsort_gen()

void qsort_gen ( void * list,
size_t nitems,
int(* compar )(const void *, size_t, size_t),
void(* swapr )(void *, size_t, size_t) )

Sort an arbitrary list of items using the qsort algorithm. interpreted by this function but passed to the compar and swapr functions.

Parameters
nitemsThe number of items in the list.
comparThe comparator function. The function receives the pointer to the list to be sorted and the indices of the elements to be compared.
swaprThe function used to swap two elements within the list. The function receives the pointer to the list to be sorted and the indices of the elements to be compared.

◆ qsort_gen_memswap()

void qsort_gen_memswap ( void * m1,
void * m2,
size_t size )

Swaps two arbitrary blocks of memory.

Parameters
m1Pointer to the first block of memory.
m2Pointer to the second block of memory.
sizeSize of the memory blocks to be swapped.