14 #include "../ft_mem/ft_mem.h"
16 #include "../ft_math/ft_math.h"
20 unsigned char *
_at(
unsigned char *base,
size_t i,
size_t memb_size)
22 return (base + (i * memb_size));
25 void _ft_qsort(
unsigned char *base,
size_t nmemb,
size_t memb_size,
31 if (base == NULL || nmemb <= 1 || memb_size <= 0 || compar == NULL)
37 if (0 < compar(base,
_at(base, i, memb_size)))
39 _at(base, ++i_last, memb_size), memb_size);
42 ft_swap(base,
_at(base, i_last, memb_size), memb_size);
44 _ft_qsort(base, i_last, memb_size, compar);
45 if (2 <= (nmemb - i_last - 1))
46 _ft_qsort(
_at(base, i_last + 1, memb_size), nmemb - i_last - 1,
54 _ft_qsort((
unsigned char *)base, nmemb, memb_size, compar);
bool can_mulp(size_t a, size_t b)
void ft_swap(void *a, void *b, size_t bytes)
bool ft_qsort(void *base, size_t nmemb, size_t memb_size, t_compar compar)
void _ft_qsort(unsigned char *base, size_t nmemb, size_t memb_size, t_compar compar)
unsigned char * _at(unsigned char *base, size_t i, size_t memb_size)
int(* t_compar)(const void *, const void *)