From 4800d3ca472058f0161970aa55c6debb453e5d00 Mon Sep 17 00:00:00 2001 From: Charles Date: Mon, 10 Feb 2020 03:58:29 +0100 Subject: Fixing merge compilation error, Added ft_mergesort --- include/libft_algo.h | 32 +++++++++++++++++++++++--------- include/libft_mem.h | 3 ++- 2 files changed, 25 insertions(+), 10 deletions(-) (limited to 'include') diff --git a/include/libft_algo.h b/include/libft_algo.h index 4dc3353..14496dd 100644 --- a/include/libft_algo.h +++ b/include/libft_algo.h @@ -6,27 +6,41 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/01/19 07:22:57 by cacharle #+# #+# */ -/* Updated: 2020/02/10 02:21:47 by cacharle ### ########.fr */ +/* Updated: 2020/02/10 03:04:17 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ #ifndef LIBFT_ALGO_H # define LIBFT_ALGO_H -typedef int t_bool; +# include +# include +# include "libft_mem.h" +# include "libft_types.h" typedef struct { - int lo; - int hi; -} t_ftrange; + int lo; + int hi; +} t_ftrange; -typedef int (*t_ftcompar_func)(const void*, const void*); +struct s_merge_sorted_arrays +{ + void *base; + void *left; + void *right; +}; + +typedef int (*t_ftcompar_func)(const void*, const void*); -t_bool ft_is_set(void *base, size_t nel, size_t width, +t_ftbool ft_is_set(void *base, size_t nel, size_t width, t_ftcompar_func compar); -void ft_qsort(void *base, size_t nel, size_t width, +int ft_compar_int(const void *a, const void *b); +void ft_qsort(void *base, size_t nel, size_t width, t_ftcompar_func compar); -int ft_compar_int(const void *a, const void *b); +int ft_mergesort(void *base, size_t nel, size_t width, + int (*compar)(const void *, const void *)); +int ft_heapsort(void *base, size_t nel, size_t width, + int (*compar)(const void *, const void *)); #endif diff --git a/include/libft_mem.h b/include/libft_mem.h index 5465d72..af3f4b5 100644 --- a/include/libft_mem.h +++ b/include/libft_mem.h @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/01/31 10:35:57 by cacharle #+# #+# */ -/* Updated: 2020/01/31 10:35:59 by cacharle ### ########.fr */ +/* Updated: 2020/02/10 02:55:38 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -21,6 +21,7 @@ void *ft_memmove(void *dst, const void *src, size_t len); void *ft_memchr(const void *s, int c, size_t n); int ft_memcmp(const void *s1, const void *s2, size_t n); void *ft_calloc(size_t count, size_t size); +void ft_memswap(void *a, void *b, size_t size); /* ** bloat ? -- cgit