aboutsummaryrefslogtreecommitdiff
path: root/include/libft_algo.h
diff options
context:
space:
mode:
authorCharles <sircharlesaze@gmail.com>2020-02-10 06:00:35 +0100
committerCharles <sircharlesaze@gmail.com>2020-02-10 06:00:35 +0100
commitf178a21e2560d9375227dbf6751a54f12e1033b2 (patch)
treed36024d504cb7b96f300e084807c0ba0330c4a7c /include/libft_algo.h
parentfe15975761f2dcb52d360a521c5ef912d66d5e1c (diff)
downloadlibft-f178a21e2560d9375227dbf6751a54f12e1033b2.tar.gz
libft-f178a21e2560d9375227dbf6751a54f12e1033b2.tar.bz2
libft-f178a21e2560d9375227dbf6751a54f12e1033b2.zip
Added ft_bsearch, ft_lsearch, ft_lfind
Diffstat (limited to 'include/libft_algo.h')
-rw-r--r--include/libft_algo.h42
1 files changed, 27 insertions, 15 deletions
diff --git a/include/libft_algo.h b/include/libft_algo.h
index 65308b8..7223e7b 100644
--- a/include/libft_algo.h
+++ b/include/libft_algo.h
@@ -6,7 +6,7 @@
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/01/19 07:22:57 by cacharle #+# #+# */
-/* Updated: 2020/02/10 05:17:39 by cacharle ### ########.fr */
+/* Updated: 2020/02/10 05:58:26 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -18,30 +18,42 @@
# include "libft_mem.h"
# include "libft_types.h"
+typedef int (*t_ftcompar_func)(const void*, const void*);
+
typedef struct
{
- int lo;
- int hi;
-} t_ftrange;
+ int lo;
+ int hi;
+} t_ftrange;
-struct s_merge_sorted_arrays
+struct s_merge_sorted_arrays
{
- void *base;
- void *left;
- void *right;
+ void *base;
+ void *left;
+ void *right;
};
-typedef int (*t_ftcompar_func)(const void*, const void*);
+typedef struct s_ft_search_const
+{
+ const void *key;
+ t_ftcompar_func compar;
+} t_ftsearch_const;
-t_ftbool 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);
-int ft_compar_int(const void *a, const void *b);
-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_mergesort(void *base, size_t nel, size_t width,
+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 ft_heapsort(void *base, size_t nel, size_t width,
int (*compar)(const void *, const void *));
-void ft_reverse(void *base, size_t nel, size_t width);
+void ft_reverse(void *base, size_t nel, size_t width);
+void *ft_bsearch(const void *base, size_t nel, size_t width,
+ t_ftsearch_const *consts);
+void *ft_lfind(const void *base, size_t *nelp, size_t width,
+ t_ftsearch_const *consts);
+void *ft_lsearch(const void *base, size_t *nelp, size_t width,
+ t_ftsearch_const *consts);
#endif