aboutsummaryrefslogtreecommitdiff
path: root/include/libft_algo.h
blob: 14496dd9807da8ae8ca565dc5f6eafb15718384a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   ft_algo.h                                          :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: cacharle <marvin@42.fr>                    +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/01/19 07:22:57 by cacharle          #+#    #+#             */
/*   Updated: 2020/02/10 03:04:17 by cacharle         ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#ifndef LIBFT_ALGO_H
# define LIBFT_ALGO_H

# include <stdlib.h>
# include <stddef.h>
# include "libft_mem.h"
# include "libft_types.h"

typedef struct
{
	int			lo;
	int			hi;
}				t_ftrange;

struct			s_merge_sorted_arrays
{
	void		*base;
	void		*left;
	void		*right;
};

typedef int		(*t_ftcompar_func)(const void*, const void*);

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,
						t_ftcompar_func compar);
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