|
libft
|
General-purpose sorting utilities including a custom quicksort. More...
Files | |
| file | ft_qsort.c |
| Generic quicksort implementation with fallback to insertion sort. | |
| file | ft_sorting.h |
| Sorting utility functions and comparators. | |
Macros | |
| #define | QSORT_THRESHOLD 10 |
Functions | |
| int | double_cmp (const void *a, const void *b) |
| Comparison function for two doubles. | |
| void | ft_qsort (void *base, size_t nmemb, size_t size, int(*cmp)(const void *, const void *)) |
| Sorts an array using quicksort and insertion sort fallback. | |
| int | int_cmp (const void *a, const void *b) |
| Comparison function for two integers. | |
General-purpose sorting utilities including a custom quicksort.
This group contains functions related to sorting arrays using a generic implementation of the quicksort algorithm. It also includes basic comparator functions for integers and doubles that can be passed to ft_qsort.
| #define QSORT_THRESHOLD 10 |
#include <include/ft_sorting.h>
Threshold to switch sort strategy
| int double_cmp | ( | const void * | a, |
| const void * | b | ||
| ) |
#include <include/ft_sorting.h>
Comparison function for two doubles.
Compares the two doubles pointed to by a and b and returns a standard comparator result.
| a | Pointer to the first double. |
| b | Pointer to the second double. |
a < b, 0 if equal, positive if a > b.| void ft_qsort | ( | void * | base, |
| size_t | nmemb, | ||
| size_t | size, | ||
| int(*)(const void *, const void *) | cmp | ||
| ) |
#include <include/ft_sorting.h>
Sorts an array using quicksort and insertion sort fallback.
Sorts an array of any type using a generic quicksort implementation. Falls back to insertion sort for small subarrays.
| base | Pointer to the first element of the array. |
| nmemb | Number of elements in the array. |
| size | Size in bytes of each element. |
| cmp | Comparison function returning:
|
| int int_cmp | ( | const void * | a, |
| const void * | b | ||
| ) |
#include <include/ft_sorting.h>
Comparison function for two integers.
Compares the two integers pointed to by a and b and returns a standard comparator result.
| a | Pointer to the first integer. |
| b | Pointer to the second integer. |
a < b, 0 if equal, positive if a > b.