From 14db635d9afa8457e3dbd3563394e5a06f62d962 Mon Sep 17 00:00:00 2001 From: salaaad2 Date: Wed, 25 Mar 2020 14:40:34 +0100 Subject: fuck fuck fuck --- src/ft_sort_s_t.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/ft_sort_s_t.c (limited to 'src/ft_sort_s_t.c') diff --git a/src/ft_sort_s_t.c b/src/ft_sort_s_t.c new file mode 100644 index 0000000..f015abc --- /dev/null +++ b/src/ft_sort_s_t.c @@ -0,0 +1,37 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_sort_s_t.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rbousset +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/24 20:22:45 by rbousset #+# #+# */ +/* Updated: 2020/03/09 18:56:01 by rbousset ### ########lyon.fr */ +/* */ +/* ************************************************************************** */ + +#include +#include +#include +#include +#include +#include + +/*clearpilled*/ + +void + ft_sort_s_t(t_cub *cl, float dist_tab[8][4096]) +{ + uint16_t i; + int32_t tmp; + + i = 0; + while (i < cl->mlist.sprite_var) + { + if (dist_tab[i][0] < dist_tab[i + 1][0]) + { + i = 0; + } + i++; + } +} -- cgit v1.2.3 From e9458c5d50f43a66d575478a0cbc14d8f6e42baa Mon Sep 17 00:00:00 2001 From: salad Date: Wed, 25 Mar 2020 15:44:53 +0100 Subject: what the fuck les amis --- src/ft_sort_s_t.c | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) (limited to 'src/ft_sort_s_t.c') diff --git a/src/ft_sort_s_t.c b/src/ft_sort_s_t.c index f015abc..702d5e6 100644 --- a/src/ft_sort_s_t.c +++ b/src/ft_sort_s_t.c @@ -19,19 +19,41 @@ /*clearpilled*/ +void +ft_init_st(int32_t st_o[8]) +{ + int8_t i; + + i = -1; + while (++i < 3) + st_o[i] = i; +} + void ft_sort_s_t(t_cub *cl, float dist_tab[8][4096]) { - uint16_t i; + int16_t i; int32_t tmp; + float *tmp_i; - i = 0; - while (i < cl->mlist.sprite_var) + i = -1; + ft_init_st(cl->mlist.st_o); + tmp_i = ft_calloc(sizeof(int32_t), 4096); + while (++i < cl->mlist.sprite_var) { if (dist_tab[i][0] < dist_tab[i + 1][0]) { - i = 0; + tmp = cl->mlist.st_o[i]; + cl->mlist.st_o[i] = cl->mlist.st_o[i + 1]; + cl->mlist.st_o[i + 1] = tmp; + ft_memcpy(tmp_i, dist_tab[i], 4096); + ft_memcpy(dist_tab[i], dist_tab[i + 1], 4096); + ft_memcpy(dist_tab[i + 1], tmp_i, 4096); + i = -1; } - i++; } + i = -1; + while (++i < 3) + printf("%d\n", cl->mlist.st_o[i]); + puts("-------------------------"); } -- cgit v1.2.3 From 30d5ae61f527a6cf606e6ca8546311fde678579a Mon Sep 17 00:00:00 2001 From: salad Date: Wed, 25 Mar 2020 16:02:09 +0100 Subject: j'aime trier --- src/ft_sort_s_t.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'src/ft_sort_s_t.c') diff --git a/src/ft_sort_s_t.c b/src/ft_sort_s_t.c index 702d5e6..eaf866e 100644 --- a/src/ft_sort_s_t.c +++ b/src/ft_sort_s_t.c @@ -17,15 +17,15 @@ #include #include -/*clearpilled*/ +/*divine*/ -void -ft_init_st(int32_t st_o[8]) +static void + ft_init_st(uint16_t sprite_var, int32_t st_o[8]) { int8_t i; i = -1; - while (++i < 3) + while (++i < sprite_var) st_o[i] = i; } @@ -37,10 +37,10 @@ void float *tmp_i; i = -1; - ft_init_st(cl->mlist.st_o); - tmp_i = ft_calloc(sizeof(int32_t), 4096); + if (!(tmp_i = ft_calloc(sizeof(int32_t), 4096))) + return ; + ft_init_st(cl->mlist.sprite_var, cl->mlist.st_o); while (++i < cl->mlist.sprite_var) - { if (dist_tab[i][0] < dist_tab[i + 1][0]) { tmp = cl->mlist.st_o[i]; @@ -51,9 +51,4 @@ void ft_memcpy(dist_tab[i + 1], tmp_i, 4096); i = -1; } - } - i = -1; - while (++i < 3) - printf("%d\n", cl->mlist.st_o[i]); - puts("-------------------------"); } -- cgit v1.2.3 From 0734c879193ef0cb9aaf7a8e38c198f6661de192 Mon Sep 17 00:00:00 2001 From: salad Date: Wed, 25 Mar 2020 16:06:10 +0100 Subject: norme, TODO: liks --- src/ft_sort_s_t.c | 39 +++++++++++++++++---------------------- 1 file changed, 17 insertions(+), 22 deletions(-) (limited to 'src/ft_sort_s_t.c') diff --git a/src/ft_sort_s_t.c b/src/ft_sort_s_t.c index eaf866e..c1378c7 100644 --- a/src/ft_sort_s_t.c +++ b/src/ft_sort_s_t.c @@ -13,42 +13,37 @@ #include #include #include -#include -#include -#include - -/*divine*/ static void - ft_init_st(uint16_t sprite_var, int32_t st_o[8]) + ft_init_st(uint16_t sprite_var, int32_t st_o[8]) { - int8_t i; + int8_t i; - i = -1; - while (++i < sprite_var) - st_o[i] = i; + i = -1; + while (++i < sprite_var) + st_o[i] = i; } void - ft_sort_s_t(t_cub *cl, float dist_tab[8][4096]) + ft_sort_s_t(t_cub *cl, float dist_tab[8][4096]) { int16_t i; int32_t tmp; float *tmp_i; i = -1; - if (!(tmp_i = ft_calloc(sizeof(int32_t), 4096))) - return ; - ft_init_st(cl->mlist.sprite_var, cl->mlist.st_o); + if (!(tmp_i = ft_calloc(sizeof(int32_t), 4096))) + return ; + ft_init_st(cl->mlist.sprite_var, cl->mlist.st_o); while (++i < cl->mlist.sprite_var) if (dist_tab[i][0] < dist_tab[i + 1][0]) - { - tmp = cl->mlist.st_o[i]; - cl->mlist.st_o[i] = cl->mlist.st_o[i + 1]; - cl->mlist.st_o[i + 1] = tmp; - ft_memcpy(tmp_i, dist_tab[i], 4096); - ft_memcpy(dist_tab[i], dist_tab[i + 1], 4096); - ft_memcpy(dist_tab[i + 1], tmp_i, 4096); - i = -1; + { + tmp = cl->mlist.st_o[i]; + cl->mlist.st_o[i] = cl->mlist.st_o[i + 1]; + cl->mlist.st_o[i + 1] = tmp; + ft_memcpy(tmp_i, dist_tab[i], 4096); + ft_memcpy(dist_tab[i], dist_tab[i + 1], 4096); + ft_memcpy(dist_tab[i + 1], tmp_i, 4096); + i = -1; } } -- cgit v1.2.3 From fb50b38dbffc812297b1d3980a19ecff070fda4a Mon Sep 17 00:00:00 2001 From: salad Date: Wed, 25 Mar 2020 16:38:34 +0100 Subject: pourquoi se priver de stack --- src/ft_sort_s_t.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/ft_sort_s_t.c') diff --git a/src/ft_sort_s_t.c b/src/ft_sort_s_t.c index c1378c7..24ed358 100644 --- a/src/ft_sort_s_t.c +++ b/src/ft_sort_s_t.c @@ -29,11 +29,9 @@ void { int16_t i; int32_t tmp; - float *tmp_i; + float tmp_i[4096]; i = -1; - if (!(tmp_i = ft_calloc(sizeof(int32_t), 4096))) - return ; ft_init_st(cl->mlist.sprite_var, cl->mlist.st_o); while (++i < cl->mlist.sprite_var) if (dist_tab[i][0] < dist_tab[i + 1][0]) -- cgit v1.2.3