From eff9be76b9aa47e233af7e8651c9a665818b94cc Mon Sep 17 00:00:00 2001 From: = <=> Date: Fri, 5 Dec 2025 19:15:22 +0100 Subject: [PATCH] Added pqrtial quicksort --- algorithm_quicksort.c | 41 +++++++++++++++++++++++++++++++++++++++++ pushswap.h | 7 +------ 2 files changed, 42 insertions(+), 6 deletions(-) create mode 100644 algorithm_quicksort.c diff --git a/algorithm_quicksort.c b/algorithm_quicksort.c new file mode 100644 index 0000000..71e6250 --- /dev/null +++ b/algorithm_quicksort.c @@ -0,0 +1,41 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* algorithm_quicksort.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: agilliar +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2025/12/05 19:07:14 by agilliar #+# #+# */ +/* Updated: 2025/12/05 19:15:04 by agilliar ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "pushswap.h" + +static void quicksort_sift_n(const t_stacks *stacks, size_t n, t_psval pivot, t_closure cb) +{ + size_t a; + size_t b; + + a = 0; + b = 0; + while (a + b < n) + { + if (clist_get_at(&stacks->a, 0) > pivot) + { + a++; + (cb.func)(cb.data, OP_RA); + } + else + { + b++; + (cb.func)(cb.data, OP_PB); + } + } + +} + +void algoritm_quicksort(const t_stacks *stacks, t_closure cb) +{ + +} diff --git a/pushswap.h b/pushswap.h index eab2671..a2e8d31 100644 --- a/pushswap.h +++ b/pushswap.h @@ -6,7 +6,7 @@ /* By: agilliar +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/12/02 11:02:44 by agilliar #+# #+# */ -/* Updated: 2025/12/03 16:25:25 by agilliar ### ########.fr */ +/* Updated: 2025/12/05 19:08:52 by agilliar ### ########.fr */ /* */ /* ************************************************************************** */ @@ -75,11 +75,6 @@ typedef struct s_ops t_closure ops[11]; } t_ops; -# define STACKID_A false -# define STACKID_B true - -typedef bool t_stackid; - void cheatexit(int errcode); void *cheatalloc(size_t len); -- 2.51.0