diff options
| author | Tyge Lovset <[email protected]> | 2023-04-09 10:37:16 +0200 |
|---|---|---|
| committer | Tyge Lovset <[email protected]> | 2023-04-09 10:37:16 +0200 |
| commit | 0a32a32b06170ad588ec837a86df9e3f419c2f4d (patch) | |
| tree | 4518d627bc9a4e270e9d6aaed29ac24e959f38b5 /docs/ccommon_api.md | |
| parent | 43120f2863a67db416ec3b379eb820e2704cafb7 (diff) | |
| download | STC-modified-0a32a32b06170ad588ec837a86df9e3f419c2f4d.tar.gz STC-modified-0a32a32b06170ad588ec837a86df9e3f419c2f4d.zip | |
Final commit before 4.2 release?
Diffstat (limited to 'docs/ccommon_api.md')
| -rw-r--r-- | docs/ccommon_api.md | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/docs/ccommon_api.md b/docs/ccommon_api.md index 90191e40..bc0a39ba 100644 --- a/docs/ccommon_api.md +++ b/docs/ccommon_api.md @@ -1,6 +1,4 @@ -# STC [ccommon](../include/stc/ccommon.h): Generic algorithms and macros - -The following macros are recommended to use, and they safe/have no side-effects. +# STC Algorithms --- ## Ranged for-loops @@ -205,6 +203,23 @@ if (it.ref) cmap_str_erase_at(&map, it); c_erase_if(i, csmap_str, map, cstr_contains(i.ref, "hello")); ``` +### csort - two times faster qsort + +When very fast array sorting is required, **csort** is about twice as fast as *qsort()*, and often simpler to use. +You may customize `i_tag` and the comparison function `i_cmp` or `i_less`. + +There is a [benchmark/test file here](../misc/benchmarks/various/csort_bench.c). +```c +#define i_val int +#include <stc/algo/csort.h> + +int main() { + int array[] = {5, 3, 5, 9, 7, 4, 7, 2, 4, 9, 3, 1, 2, 6, 4}; + csort_int(array, c_arraylen(array)); +} +``` + + ### c_new, c_delete - `c_new(Type, val)` - Allocate *and init* a new object on the heap |
