]> Untitled Git - axy/ft/pushswap.git/commitdiff
Added pqrtial quicksort
author= <=>
Fri, 5 Dec 2025 18:15:22 +0000 (19:15 +0100)
committer= <=>
Fri, 5 Dec 2025 18:15:22 +0000 (19:15 +0100)
algorithm_quicksort.c [new file with mode: 0644]
pushswap.h

diff --git a/algorithm_quicksort.c b/algorithm_quicksort.c
new file mode 100644 (file)
index 0000000..71e6250
--- /dev/null
@@ -0,0 +1,41 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   algorithm_quicksort.c                              :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: agilliar <marvin@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   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)
+{
+       
+}
index eab267160c1328c2d80e561c6df62125a1d412ce..a2e8d31d897cdf9e2d7f19528cf39043a04ab679 100644 (file)
@@ -6,7 +6,7 @@
 /*   By: agilliar <marvin@42.fr>                    +#+  +:+       +#+        */
 /*                                                +#+#+#+#+#+   +#+           */
 /*   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);