NAME=push_swap
-SRCS=algorithm_complex.c algorithm_leafsort.c algorithm_simple.c cheatalloc.c clist.c closure.c leaf_sort.c leaf_sort_index.c leaf_sort_parse.c list.c main_pushswap.c op_output.c op_p.c op_parse.c op_r.c op_rr.c op_s.c ops.c ops_groups.c ops_optimizer.c output.c psval.c slice.c splitsort.c splitsort_final.c splitsort_iter.c splitsort_part.c stack.c stacks.c stacks_get.c
+SRCS=algorithm_complex.c algorithm_leafsort.c algorithm_simple.c cheatalloc.c clist.c closure.c leaf_sort.c leaf_sort_index.c leaf_sort_parse.c list.c main_pushswap.c op_count.c op_output.c op_p.c op_parse.c op_r.c op_rr.c op_s.c ops.c ops_groups.c ops_optimizer.c output.c psval.c slice.c splitsort.c splitsort_final.c splitsort_iter.c splitsort_part.c stack.c stacks.c stacks_get.c
RESSRCS=_res_leaf_sort_lookup.h
--- /dev/null
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* op_count.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: clefrere <clefrere@student.42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2025/12/16 12:28:05 by clefrere #+# #+# */
+/* Updated: 2025/12/16 15:40:32 by clefrere ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include "leaf_sort.h"
+
+static void op_count_inner(size_t *data, t_stacks *stack)
+{
+ (void) stack;
+ data[0]++;
+}
+
+t_closure op_count(size_t *dst)
+{
+ t_closure res;
+
+ dst[0] = 0;
+ res.data = dst;
+ res.func = &op_count_inner;
+ return (res);
+}
+
+t_ops ops_count(t_ops_count *counter)
+{
+ t_ops res;
+ t_op op;
+
+ op = OP_SA;
+ while (op <= OP_RRR)
+ {
+ res.ops[op] = op_count(&counter->counters[op]);
+ op++;
+ }
+ return (res);
+}
/* By: clefrere <clefrere@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/12/02 11:02:44 by agilliar #+# #+# */
-/* Updated: 2025/12/16 14:54:32 by agilliar ### ########.fr */
+/* Updated: 2025/12/16 15:40:10 by clefrere ### ########.fr */
/* */
/* ************************************************************************** */
t_closure ops[11];
} t_ops;
+typedef struct s__ops_count
+{
+ size_t counters[11];
+} t_ops_count;
+
typedef struct s_list
{
size_t len;
t_closure op_output(t_op op);
+t_closure op_count(size_t *dst);
+t_ops ops_count(t_ops_count *counter);
+
t_closure op_compose(t_closure first, t_closure second);
t_ops ops_compose(t_ops lhs, t_ops rhs);
t_ops ops_init(t_closure (*gen)(t_op));