PebbleOS
Loading...
Searching...
No Matches
Typedefs | Functions

In-place sorting of small arrays. More...

Typedefs

typedef int(* SortComparator) (const void *, const void *)
 qsort()-style comparator: negative, 0 or positive when a < b, a == b or a > b.
 

Functions

void sort_bubble (void *array, size_t num_elem, size_t elem_size, SortComparator comp)
 Sort an array in ascending order with a quadratic exchange sort.
 

Detailed Description

In-place sorting of small arrays.

Typedef Documentation

◆ SortComparator

typedef int(* SortComparator) (const void *, const void *)

qsort()-style comparator: negative, 0 or positive when a < b, a == b or a > b.

Function Documentation

◆ sort_bubble()

void sort_bubble ( void *  array,
size_t  num_elem,
size_t  elem_size,
SortComparator  comp 
)

Sort an array in ascending order with a quadratic exchange sort.

Meant for small arrays; it is not stable.

Parameters
[in,out]arrayArray to sort.
num_elemNumber of elements.
elem_sizeSize of an element in bytes.
compComparator.